Welcome Guest, Not a member yet? Register   Sign In
Processing multiple form posts in one submission.
#1

[eluser]techguy101[/eluser]
Hi There,

I'm working on a project now where the time has come to manage multiple form submissions in one page request.

Here is an example of what i'm trying to achieve:

A lesson booking page where there are multiple bookings printed in a table. After each booking I will have tick boxes for: paid, cancelled, same time next weeke etc. I will then want to be able to make the relevant ticks beside each booking and click submit only once at the end of the page.

Is this possible with CI or even just PHP?

I was thinking that there might be some kind of facility in PHP to iterate through the different forms.

Any ideas on this would be greatly appreciated.

Regards.
#2

[eluser]danmontgomery[/eluser]
You would have to submit the forms with javascript or make them all one form.
#3

[eluser]pickupman[/eluser]
You could probably achieve this with one form. You can label your inputs according the section of the form they are in. Also, adding [] to a field name will allow you to post the fields as an array.
Code:
echo '<p>This weeks bookings</p>';
echo form_open('lesson/add');

echo form_label('Paid','paid');
echo from_checkbox('section1_paid[]');

echo form_label('Paid','paid');
echo from_checkbox('section1_paid[]');

echo form_label('Paid','paid');
echo from_checkbox('section1_paid[]');

echo '<p>Next weeks bookings</p>';

echo form_label('Paid','paid');
echo from_checkbox('section2_paid[]');

echo form_label('Paid','paid');
echo from_checkbox('section2_paid[]');


echo form_close();

//Process in controller
$section1_paid = $this->input->post('section1_paid');
$section2_paid = $this->input->post('section2_paid');

foreach($section1_paid as $paid)
{
   //Do something here with values
}
//Rinse and repeat for 2nd section




Theme © iAndrew 2016 - Forum software by © MyBB