Modify Form to support an array of FieldValues
See original GitHub issueI would like to be able to have Form
control an array of inputs. For instance, if I have a form where I am allowing a user to input multiple phone numbers.
Expected Behavior
Originally I thought this would have worked by making the name
of the controlled component with the index of the FieldValue. Something like phones[0].number
which would be an object.
Actual Behavior
It does not work like this, instead I have to implement my own array of FieldValues, and control them using external state.
URL, screen shot, or Codepen exhibiting the issue
Here is my code sandbox with a demonstration of the issue.
Your Environment
- Grommet version: 2.11.1
- Browser Name and version: Brave Version 1.4.96 Chromium: 80.0.3987.132 (Official Build) (64-bit)
- Operating System and version (desktop or mobile): macOS Catalina 10.15.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
forms - How to examine existing field values and modify other ...
Check the $form array instead for the default value of the desired field, then use the states to add some behavior. Share.
Read more >jQuery compare select field values with an array before ...
I'm trying to get the values of this select field and compare it against a list of cities I have, if found any...
Read more >useFieldArray - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >Update form field values in WPForms - Bill Erickson
$entry – (array) Original $_POST global. $form_data – (array) Form settings/data. Example. My form uses number fields for Red Shirts and Blue ...
Read more >array field on form - ServiceNow Community
Can anybody help me on this? ... array field on form ... parse the strings using a fieldValue.split(','); assuming fieldValue already holds ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds reasonable. My inclination is to have FormContext.update() know how to translate a name like
person[0].name
into settingvalue['person'][0]['name'] = value
.Go for it! @g4rry420