[eluser]Evil Wizard[/eluser]
Code:
<li>
<label for="Title">Title<em> <img src="http://somesite/ci/assets/images/required_star.gif"
alt="required" /></em><?php echo form_error('customer[title][]'); ?></label>
<select name="customer[title][]">
<option value="" <?php echo set_select('customer[title][]', '', TRUE); ?> >Select a Title</option>
<option value="mr" <?php echo set_select('customer[title][]', 'mr'); ?> >Mr</option>
<option value="ms" <?php echo set_select('customer[title][]', 'ms'); ?> >Ms</option>
<option value="mrs" <?php echo set_select('customer[title][]', 'mrs'); ?> >Mrs</option>
<option value="miss" <?php echo set_select('customer[title][]', 'miss'); ?> >Miss</option>
</select>
</li>
Code:
<?php
class Form extends Controller {
function index()
{
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('array');
$this->load->helper('html');
$this->load->helper('date');
$this->load->library('form_validation');
$this->load->library('email');
// Cant seem to get post data with these
/* $data['title'] = $_POST['customer[title]'];
$data['title'] = $_POST['title'];
$data_title = $_POST['customer[title]'];
*/
// I think that will work
$data['customer']['title'] = $this->input->post('title');
// This should bring back the $_POST['customer'] value even if it is an array
$data['customer'] = $this->input->post('customer');
if ($this->form_validation->run('booking') == FALSE)
{
$data['title'] = "";
$data['message'] = "";
$this->load->view('myform' , $data);
}
else
{
// This below line was a test to try and populate the array element :(
$data['title'] = "$data_title";
$data['message'] = "Thank you, your booking has been sent!";
$this->load->view('myform' , $data);
}
} // Close Function
I hope that helps