[eluser]Unknown[/eluser]
I have looked around the internet and these forums and can't find the answer. I am trying to repopulate my form on validation failure but the fields are being repopulated with "Array" instead of the data that was posted to the controller.
Here is the controller code.
Code:
<?php
class Contact extends Controller
{
function Contact(){
parent::Controller();
}
function index(){
$this->load->library('form_validation');
$this->form_validation->set_rules('first_name', 'First Name', 'required');
$this->form_validation->set_rules('last_name', 'Last Name', 'required');
$this->form_validation->set_rules('salutation', 'Salutation', 'required');
$this->form_validation->set_rules('email_address', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
$args = array('model_line_name'=>'contact','model_name'=>null);
$this->load->view('common/header',$args);
$this->load->view('contact_us_view');
$this->load->view('common/footer');
}
else
{
echo "Form Success";
}
}
}
?>
The View is as follows
Code:
<div id="contact_form">
<?php
echo validation_errors();
echo form_open('contact');
echo "<label for='salutation'>Salutation:</label>";
?>
<select name ="salutation" id ="salutation">
<option value ="Mr." <?php echo set_select('salutation','Mr.',TRUE); ?> >Mr.</option>
<option value ="Mrs." <?php echo set_select('salutation','Mrs.'); ?> >Mrs.</option>
<option value ="Ms." <?php echo set_select('salutation','Ms.'); ?> >Ms.</option>
<option value ="Dr." <?php echo set_select('salutation','Dr.'); ?> >Dr.</option>
</select>
<?php
echo "<label for='first_name'>First Name:</label>";
echo form_input('first_name',array('value'=>set_value('first_name'),'id'=>'first_name'));
echo "<label for='last_name'>Last Name:</label>";
echo form_input('last_name',array('value'=>set_value('last_name'),'id'=>'last_name'));
echo "<label for='email_address'>Email:</label>";
echo form_input('email_address',array('value'=>set_value('email_address'),'id'=>'email_address'));
echo "<label for='phone_number'>Phone:</label>";
echo form_input('phone_number',array('value'=>set_value('phone_number'),'id'=>'phone_number'));
echo form_submit('contact_submit','Contact Us');
echo form_fieldset_close();
?>
</div>
I am not sure what I am missing. I will keep trying various permutations of code but it would be helpful if someone else has already characterized this issue.
Thanks,
Daniel