[eluser]JustinWyllie[/eluser]
Hi
I am quite new to Code Igniter.
I have a form like the one below. Whenever I post it to the controller and run the validation it is always in every case invalid even with both fields filled in or even without the rules defined at all.
The form is posted to a different url than the one on which the form is displayed. It is not an ajax post - I thought that might be the problem but it is now posted by the browser in response to the submit button being pressed.
Code:
<form action="http://domain/clients/admin/business/ajax_business" method="post" accept-charset="utf-8">
<label for="first_name">First Name</label>
<input type="input" name="first_name"><br>
<label for="last_name">Last Name</label>
<input type="input" name="last_name"><br>
<input type="submit" name="submit" value="Update">
</form>
Code:
public function ajax_business() {
$this->load->helper(array('form', 'url'));
$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');
$response = new stdClass();
if ($this->form_validation->run() == FALSE)
{
//whatever i do this block is always run
$response->result = false;
}
else
{
$response->result = true;
}
}
Thanks
--Justin Wyllie