One component with multiple instance
Closed this issue · 1 comments
attiqeurrehman commented
Hi,
I have component Address which will be used in a long form at least twice. Something like this:
<Formsy.Form>
<Address name="employeeAddress"/>
<Address name="studentAddress"/>
</Formsy.Form>
But on form submit I only get one address object in the model.
I want it to display both with different names employeeAddress and studentAddress.
Thanks,
Attiqe
attiqeurrehman commented
I was able to do it by getting the name of prop in render function and then adding it with the component.
var componentName = this.props.name;
<Formsy.Input
name={componentName + '.country'}
value=""
type="text"
placeholder="Country/Region" />