I have a form.
<form class="form-horizontal" name="canForm" ng-submit="stepSubmit()" novalidate>
It is called "canForm" as above.
Within this form.. I need a subform for a repeating block of requirements.
I define this form
<div ng-form="licencesForm">
within the "canForm" above.
When I submit the licencesForm
for my repeating block I make sure that I set form.$setPristine()
in the controller.
However, when I submit the main canForm
, this form picks up on the required
fields in my subform and says the main form is invalid.
I cannot understand this. The ng-form directive should be an isolated scope and the parent form should not pick up on the validation requirements of the fields in this subform right?
If the subform is valid, the main form should also be valid shouldn't it?
See http://plnkr.co/edit/gkbJNAV95MQ9SGLeMvlg?p=preview
When you add something in the subform it sets the form to $setPristine() and the subform is valid but clicking submit the main form says the form is not valid even though the subform is valid?
if there is a parent form and sub form then parent form will be valid only when all subforms are valid..
<form class="form-horizontal" name="canForm" ng-submit="stepSubmit()" novalidate>
and there is a subform
<div ng-form="licencesForm">
then canForm will be valid only when all licencesForm will be valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With