Closed abhisheksaraiya closed 8 years ago
resetModel
should update those values. Could you please reproduce your issue using issue.angular-formly.com? It will help us determine what exactly the problem is that you're describing and how it could be fixed. Thanks!
Here are the steps to reproduce the issue: http://jsbin.com/jonocawunu/edit?html,js,output
1) In the beginging when the page is loaded in jsbin, please note the values $pristine and $dirty for FORM with name : "vm.form". They would be Values for FORM: "$dirty": false, "$pristine": true, Values for input field: "$dirty": false, "$pristine": true,
2) Now if you write anything in the input box in the form the values will change to Values for FORM: "$dirty": true, "$pristine": false, Values for input field: "$dirty": true, "$pristine": false,
This is OK!
3) Now when you click on reset button (thus calling resetModel()), the values change to: Values for FORM: "$dirty": true, "$pristine": false, Values for input field: "$dirty": false, "$pristine": true,
The issue is that after resetModel is called, the values for the input field are reset as expected but for the form ($pristine,$dirty) are not reset!
Looks like after we call resetModel
on all the individual fields (right here) we need to set the form's touched
and pristine
state like we do with the individual fields (here).
I'm open to a pull request for this! Anyone's welcome to try. Just follow these instructions
@kentcdodds is this issue still open? I checked it out the other day but i'm just seeing that I misread the comments :hear_no_evil:
This issue should be closed I think. Let me know if you experience otherwise!
I still see this in formly 7.2.3. after resetModel vm.form.$pristine equals false and vm.form.$dirty equals true. They should represent a propagated calculation from the fields $pristine and $dirty.
@janneman001 could you provide an example of this behavior?
I retested with latest 7.3.9. Same behaviour. I have no experience with js bin. But i will try. I experienced the issue in a form with mysql backend code. I will try to make a smaller reproduction example if time permits.
Here you can use this as a starter, then just post the link in here :+1:
My bad. I was fighting with an incorrect datepicker type field. I re-verified with 7.3.9 it is alright in 7.3.9.
Calling resetModel() on the options resets the field $pristine and $untouched values on each field nicely but the $pristine on the main form is left unchanged. Is there a reason why these are left out in the resetModel call?