-1

I'm using codeigniter for my project where I have situation to submit two different but one in another. Can I add one form into another form?

So it'll look like this:

<?php echo form_open('controller1');?>
// All form1 stuff here

  <?php echo form_open_multipart('controller2')?>

  //All form2 stuff here
  //Form2 submit button

  <?php echo form_close();?>

//Form1 submit button
<?php echo form_close();?>

Will codeigniter allow me to do this? I searched for while for this problem but didn't find for my case. Or is there any another way to do this.

Any help is appreciated.

Regards,
Vaibhav M.

Vaibhav Mandlik
  • 51
  • 2
  • 13
  • Some context would be helpful. Why do you need to do this? Why not submit one single form and reroute your data from your controller to different models? – MrCujo Jul 22 '18 at 17:46
  • 1
    https://stackoverflow.com/questions/26536861/are-nested-forms-valid-in-html5 – Atural Jul 22 '18 at 18:31
  • 1
    Nothing to do with ci, and no, it isn't allowed/valid – Alex Jul 22 '18 at 19:59
  • 1
    Possible duplicate of [Are nested forms valid in HTML5?](https://stackoverflow.com/questions/26536861/are-nested-forms-valid-in-html5) – Vickel Jul 22 '18 at 22:29
  • @MrCujo I have two different operations performed by those forms – Vaibhav Mandlik Jul 23 '18 at 18:04
  • @sintakonte I have mentioned will it work in CI not in html. – Vaibhav Mandlik Jul 23 '18 at 18:05
  • @Alex yes you were right I tried and got error – Vaibhav Mandlik Jul 23 '18 at 18:07
  • @Vickel I asked it for CI not for HTML then why you are relating it with that question – Vaibhav Mandlik Jul 23 '18 at 18:08
  • 2
    is this a serious question? first you can try it by yourself if it is working or not in ci - its not that hard to try this out... and second it doesn't matter if that works or it doesn't work - nested forms are invalid html which sooner or later will lead to problems - either you are capable to learn such things or imho you shouldn't ask this kind of question – Atural Jul 23 '18 at 18:16
  • @sintakonte yes I tried it and got the error. I asked just clarify my doubt. If it is a dumb question in your opinion then I'm really sorry I'll delete it. – Vaibhav Mandlik Jul 24 '18 at 11:57
  • @Alex can you give your answer in answer section so I can mark it as correct answer? – Vaibhav Mandlik Jul 25 '18 at 16:17

1 Answers1

0

Here is the answer:

No, we can't use nested forms in codeigniter. As displayed in the question, inner form executes successfully but outer form could not execute.

As user Alex told codeigniter does not allow nested forms. As well as other users said it is not valid in HTML too. As codeigniter is a part of HTML it does not allow like it's parent policies (Didn't found proper word for it).

Why? The reason is in this question.

Vaibhav Mandlik
  • 51
  • 2
  • 13