Field with Array of objects (Unified Mode)
See original GitHub issueI’m having a field tags
which is supposed to be an array of objects. Using react-select with multi
I’m able to add tag objects (with an id
and a name
) to the array (Note that that id
and name
are not editable, you can just add/remove objects).
Starting with an empty array this works flawlessly, but when initializing the form with an object which has already some tags the field’s value
always returns the inital array. I did a little bit of debugging and discovered that when I start with an emtpy array field.hasNestedFields
is false
while when starting with a pre-populated one it changes to true
.
export const fields = [
//... some other fields...
{
name: 'tags',
label: 'Tags',
value: []
}
]
// .....
const form = new EditForm({fields}, {plugins});
//... load some item
form.update(item);
// the field component
class TagInput extends React.Component {
render() {
return (
<Select.AsyncCreatable
{...field.bind()}
multi
valueKey="id"
labelKey="name"
resetValue={[]}
searchable={true}
clearable={true}
loadOptions={this.getTags}
/>
)
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Array Object - A.I. Solutions
You can assign Array objects using the = operator. Note: In millisecond mode, if the number of elements is not specified, the Array...
Read more >Work with arrays | BigQuery - Google Cloud
You can construct arrays of simple data types, such as INT64 , and complex data types, such as STRUCT s. The current exception...
Read more >Create a custom action to generate an array of objects from a ...
Generate an array of objects from a list of User records. Learn how to use a Script step to iterate through a list...
Read more >Arrays - C# Programming Guide | Microsoft Learn
You declare an array by specifying the type of its elements. If you want the array to store elements of any type, you...
Read more >Working with Arrays | Unreal Engine 4.27 Documentation
Creating an Array variable can be done with the following steps. Inside your Blueprint click the Add Variable button, give the variable a...
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
Thanks for your help again, after some poking around I came up with this onChange handler:
This basically works now for me, thanks for poinint me to the onChange thing.
I’ve updated the package introducing the
struct
prop.Take a look here: https://github.com/foxhound87/mobx-react-form/blob/master/tests/data/forms/fixes/form.q1.js