.set() array as value without nested fields not working
See original GitHub issueCase (unified properties, don’t mind the field name, I’m still struggling with making things work):
role_id: {
label: 'Role',
rules: 'array',
default: [],
value: []
},
Example of bad behaviour(s):
$r.form.$('role_id').set('value', [123])
$r.form.$('role_id').value # [123]
$r.form.$('role_id').set('value', [456])
$r.form.$('role_id').value # [456]
$r.form.$('role_id').set('value', [])
$r.form.$('role_id').value # [456] <- this should be [] instead
$r.form.$('role_id').update([]) # this also doesn't work
$r.form.set('value', { role_id: [] }) # still nope
$r.form.update({ role_id: [] })
$r.form.$('role_id').value # => "a" <- wait, what
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Javascript: how to dynamically create nested objects using ...
I have an Object called "Settings" and I would like to write a function that adds new settings to that object. The new...
Read more >How can update an item in a nested array, or add ... - MongoDB
My attempted solution: Does not work. Can't use $set and $setOnInsert with the same field. exports.wordListAddorEditNOTWORKING = async (req, res) ...
Read more >Nested field type | Elasticsearch Guide [8.5] | Elastic
The nested type is a specialised version of the object data type that allows arrays of objects to be indexed in a way...
Read more >Nested Objects and Arrays - VeeValidate
vee-validate supports nested objects and arrays by using field name syntax to indicate a field's path. This allows you to structure forms easily...
Read more >Work with arrays | BigQuery - Google Cloud
You can combine arrays using functions like ARRAY_CONCAT() , and convert arrays to strings ... You can also flatten ARRAY type fields of...
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 Free
Top 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
All right, I dug deeper and I think the problem actually lies between the chair and the computer. This works:
I realize that this is by design but it might be a good idea to write down an explanation of differences between
set(value)
/set('value', value)
,update()
andsync()
. I’m afraid the documentation doesn’t really differentiate between those three. I will be writing a blogpost this/next week about my experiences and tips for mobx-react-form so if you’d be so kind to just give a short explanation here, I’ll be very happy to include it and you could link the comment in FAQ 😃Anyway thank you for expressing your experience with the package. It is good to understand a different point of view in order to make a better documentation. Let me know if you have more questions. Thanks!