angular-input-modified
angular-input-modified copied to clipboard
Modified state gets screwed when a subform is toggled
Hi @slavafomin, that's a great library, really liking it.
Here's an issue I came across when working with "nested" forms. I've checked that it occurs on versions 2.3.2 and 2.4.2 (possibly others). I have a form
with a nested ng-form
, the former gets toggled with ng-if
. It looks like I can trick it into a "modified" state.
Here's the Plunker: https://plnkr.co/edit/YuYuG6M3SGWYiFE3jBKa?p=preview.
- Start with a form with selected checkbox "B":
- Select option "foo" in the sub-form. The form is modified as expected:
- Unselect checkbox "B". The form is still modified:
- Select option "B" again. The form values are now different from the starting ones, but it's no longer marked as modified:
Please let me know if there's a workaround and/or fix. Appreciate your help!
There's a workaround to reset the subform to a "default" state. In the case of the above example, we can clear the subform when the box B is unchecked. We're going loose the state of the subform, but the modified
flag will stay correct.
https://plnkr.co/edit/UiV4iJGLLr611gweWxHj?p=preview