form.update() populates 'initial' property in array field.
See original GitHub issueHello. I have next fields.
fields: [
...
{
name: 'aliases',
label: 'Alias domains list',
value: [],
bindings: 'List',
options: {
validateOnChange: true
}
}
...
]
Custom binding is very simple and doesn’t refer to the issue.
bindings() {
return {
List: {
id: 'id',
name: 'name',
type: 'type',
value: 'items',
label: 'label',
placeholder: 'placeholder',
disabled: 'disabled',
onChange: 'onChange',
onBlur: 'onBlur',
onFocus: 'onFocus',
autoFocus: 'autoFocus'
}
};
}
In a constructor of my component I do following:
this.form = new Form();
this.form.update(this.store.activeRule);
Active rule is an object with initial values. For example aliases
property contains an observable array with values [‘123’, ‘456’]. After this.form.update(this.store.activeRule);
‘aliases’ field contains initial array not only in value
property, but in initial
too.
Because of this when I do this.form.$('aliases').sync(aliases);
, I can’t update the field with new values. And it works fine when an initial array is empty.
I checked how form.update()
works for other fields and saw that initial
property wasn’t populated.
I don’t think that it is a correct behavior, but maybe I don’t understand something.
I will be glad to any help.
Thanks in advance.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
@foxhound87 I’ve used
update()
instead ofsync()
and it works. Thank you.@foxhound87 Thanks! Looks like
set()
does in fact work. Great library, by the way.