[eluser]charlie spider[/eluser]
in the administrative backend for a product page, i have all of the product details on one page.
it is broken up into multiple forms so that minor edits to one section of the product details do not have to submit and process the entire page's worth of data.
i'm using the standard CI form validation, so the forms submit back to the same controller for the page that the forms are on.
my view looks like this:
Code:
$attributes = array('name' => 'boot_text1', 'id' => 'boot_text1');
echo form_open('boot/' . $boot->bootID, $attributes);
// input stuff here
echo form_submit('submit_text', 'Update Boot Text' );
echo form_close();
// more forms here
$attributes = array('name' => 'boot_image1', 'id' => 'boot_image1');
echo form_open_multipart('boot/' . $boot->bootID, $attributes);
// input stuff here
echo form_submit('submit_image1', 'Upload Image' );
echo form_close();
// more forms here
$attributes = array('name' => 'size_chart', 'id' => 'size_chart');
echo form_open('boot/' . $boot->bootID, $attributes);
// input stuff here
echo form_submit('submit_sizechart', 'Update Size Chart' );
echo form_close();
in the controller i set the rules based on which submit button has been pressed, like this:
Code:
if ($this->input->post('submit_text'))
{
$rules['nmbr'] = "trim|required|min_length[2]|max_length[12]";
$rules['name'] = "trim|required|min_length[4]|max_length[24]";
$rules['shortDesc'] = "trim|max_length[2048]";
$rules['longDesc'] = "trim|required|max_length[4096]";
$this->validation->set_rules($rules);
}
// rule setting for other forms here
if ($this->input->post('submit_image1'))
{
$rules['pic1'] = "trim|max_length[256]";
$this->validation->set_rules($rules);
}
// rule setting for other forms here
if ($this->input->post('submit_sizechart'))
{
$rules['size_chart'] = "";
$this->validation->set_rules($rules);
}
then i set the fields:
Code:
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$fields['nmbr'] = 'Boot Number';
$fields['name'] = 'Boot Name';
$fields['shortDesc'] = 'Short Description';
$fields['longDesc'] = 'Long Description';
$fields['pic1'] = 'Boot Image 1';
// field setting for other forms here
$this->validation->set_fields($fields);
then get down to business (finally)
and just like with the rules, i test for which submit button has been pressed, and then process the data for that form
Code:
if ( $this->validation->run() == FALSE )
{
$this->load->view('boot_details', $this->data);
}
else
{
if ($this->input->post('submit_text'))
{
// code to update text
}
else if ( $this->input->post('submit_image1')
{
$this->do_upload();
}
// other form stuff here
else if ($this->input->post('submit_sizechart'))
{
// process size chart
}
}
So here's the BIG problem...
This works perfectly on my localhost, but when uploaded to the live server, everything works perfectly except the last form for the size chart !!!
what's weird is that it doesn't even register the last form being submitted.
so if i do this:
Code:
if ($this->input->post('submit_sizechart'))
{
die("you're momma is a chimp");
$rules['size_chart'] = "";
$this->validation->set_rules($rules);
}
it just sails on past as if the page loaded normally
now...
things that you might suggest after reading the above:
1) the rules for the size chart are set to nothing !!!
Code:
$rules['size_chart'] = "";
answer: so are rules for other forms that i didn't show here, and they all work fine.
2) you didn't put anything for set_fields for the size chart !!!
answer: same as #1 above. other forms have nothing for set_fields and work fine.
3) are you getting any errors ?
answer: nope! $this->validation->error_string is blank. it doesn't even hit the validation, it acts as if the the page was loading for the first time without hitting a submit button.
4) is your momma really a chimp ?
answer: no. but they may share a common ancestor from a couple hundred million years ago.
other info that may help...
the size chart is a huge mass of 230 radio buttons that are grouped in sets of three, that represent the three availability options for each boot size/width that the manufacturer has
again, this works perfectly on my localhost, i can change any of the size chart radio buttons, hit submit and the database is accurately updated. i also do not believe that this has anything to do with it because the problem seems to be with the submission of the form altogether and not the contents of the form.
i'm hoping it's something really simple that i have been overlooking because i've been staring at it for way too long now. and i am blonde, so the obvious does sometimes elude me.
anyways, i hope somebody out there can think of something that might help me.
i'm really really stumped.
thanks in advance for any and all help