Closed milanbrkic-ms closed 5 years ago
I think you have to still use update()
instead of set()
because you are re-creating the fields structure.
How to use update()
in order to remove field structure?
const field = this.form.$('resource').$(0);
field.update({
property: '123',
});
this should work for you, let me know.
const field = this.form.$('resource').$(0);
field.update({
property: {},
});
console.log(field.value) // ""
This is the solution! In order to remove nested fields we should call update
on field with empty object.
I think this feature should go in docs, because it is not intuitive at all..
Hi. I have an issues while working with unified nested fields. I have a structure similar to this one
and I initialize form by calling
this.form.update
method. The biggest problem is that in our appresource[].property
could be a string or object with properties.And when it is a object, next time I want to set new string value nothing happens.
Example:
I saw your comment in this issue https://github.com/foxhound87/mobx-react-form/issues/495#issuecomment-477545938, and get the point that is not possible to set a value, but do you know what could be a solution for my problem? I there a way to remove nested fields and then set value?
I tried to call
field.fields.clear()
but thenfield.value === []
and also not possible to set a value that is string.