0

What can happen when a submit is done in nested forms?

Will it work if I write ??? - my html file which is angularjs like below:

    <form>

        <form> 
        </form>

        <form> 
        </form>

    </form>

</form>

Optimight
  • 2,989
  • 6
  • 30
  • 48
  • no, forms within forms won't work – Professor Abronsius Jun 03 '14 at 07:33
  • Nested forms are not valid, so you probably can't! – adeneo Jun 03 '14 at 07:33
  • http://stackoverflow.com/questions/379610/can-you-nest-html-forms – Vedant Terkar Jun 03 '14 at 07:34
  • 1
    This, strictly speaking, is invalid HTML. It *is* doable though, in the sense that the page will display in some (probably broken) way. For Angular, you can use `ng-form`. It will handle partial validations (if that is what you want). I would suggest you tried to explain *why* do you want to do this. – Nikos Paraskevopoulos Jun 03 '14 at 07:36
  • 1
    You technically *can* have anything, the question is *if this gonna work or not*, in this case - it will *not*. – Bud Damyanov Jun 03 '14 at 07:36
  • @NikosParaskevopoulos, I am a beginner in angularjs, will refer to ng-form. Yes, I need partial validations. In my application user needs to select quantity for products of his/her choice which adds into Total Products selected.Then there is a creation of labels and attach it to each product. – Optimight Jun 03 '14 at 07:48

1 Answers1

1

You cannot nest forms in HTML, but in AngularJS we have ng-form which should do what you're looking for.

<form name="parentForm">
   <div ng-form="childForm">
   </div> 
</form>

The parentForm will be submitted, and both parentForm and childForm will be accessible from the $scope associated with this view.

Sunil D.
  • 17,983
  • 6
  • 53
  • 65