Reputation: 110960
Redux-form is not allowing me to set the Field name to an integer as it requires a string... How can I set the redux-form Field name to something the API can then use to record the user's option selected per Talent.
<Field
name='talent_id[' + {field.talent_id} + ']'
component={renderField}
field={field}
/>
This is not working, I'm getting Syntax error: Unexpected token
with the +
Talents.rb
id | Title
1 | Jumping
2 | Skipping
3 | Running
My API, returns Talents#Index like so:
[
{"id":1,"title":"Jumping"},
{"id":2,"title":"Skipping Rope"},
{"id":3,"title":"Running"},
{"id":4,"title":"Something Else"}
]
I then amusing the above to build a form that can later be submitted to the server.
<div>
<label>Jumping</label>
<select name="1">
<option></option>
<option value="1">XXX</option>
<option value="2">YYY</option>
<option value="3">ZZZ</option>
</select>
</div>
<div>
<label>Skipping Rope</label>
<select name="2">
<option></option>
<option value="1">XXX</option>
<option value="2">YYY</option>
<option value="3">ZZZ</option>
</select>
</div>
....
Upvotes: 0
Views: 1063
Reputation: 101
If you are use using ES5, simply like this:
<Field
name={`talent_id[${field.talent_id}]`}
component={renderField}
field={field}
/>
Upvotes: 2