formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 406 forks source link

hideExpression remove fields from the DOM but not from the MODEL #767

Open falinsin opened 6 years ago

falinsin commented 6 years ago

When fields are remove from DOM due to hideExpression, its values in the model still exits and send on submit.

Using

angular-formly v8.4.1 angular-formly-templates-bootstrap version 6.5.1

¿How can I remove hidden Fields from de model or set them as null?.

Here you have an example of the problem: http://angular-formly.com/#!/example/field-options/hide-fields

I want the checkbox state do not send in the model if checkbox is hidden.

Because if this checkbox is used for hide another third field, if we hide checkbox while is checked (using a hideExpression on it) this third field still show in the DOM which is a bit weird behavior because if checkbox is removed the third dependen field must be removed.

I have been able to observe that by simply putting null in the model the fields that are no longer in the DOM perfectly hide the dependent fields in chain

Please help to refresh model when hide fields.

Thank you in advance (sorry my bad English)