0

I want to put two Form_Open in one place. with two submit button. following its code:

<?php $att1 = array('id' => 'form1');
echo form_open('cart/invoiceprint',$att1);
echo form_input(array('name'=>'kode','type'=>'hidden','value'=>'Test01'));?><button type="submit" id="btnForm1"><i class="fa fa-print"></i> Print</button><?php form_close();?>

<?php $att2 = array('id' => 'form2');
echo form_open('cart/done',$att2);
echo form_input(array('name'=>'kode','type'=>'hidden','value'=>'Test01'));?><button type="submit" id="btnForm1"><i class="fa fa-print"></i> Done</button><?php form_close();?>

Every time I click the button "Done" always go to the page invoiceprint. how the Done button to a page done?

Muhammad Aziiz
  • 61
  • 3
  • 11

1 Answers1

1

You can't nest form tags. See this answer here Can you nest html forms?

To resolve,

Close the first form tag before opening the new form tag with

echo form_close();

Then open a new form tag, then again close it.


Another workaround is you put a single form tag on one submit button, and bind another button to post your virtual form data by javascript, by submitting it with javascript or jquery if you are using it.

Community
  • 1
  • 1
viral
  • 3,724
  • 1
  • 18
  • 32