Welcome Guest, Not a member yet? Register   Sign In
Form validation always returns false in all cases
#1

[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>
  &lt;input type="input" name="first_name"&gt;&lt;br>

  <label for="last_name">Last Name</label>
  &lt;input type="input" name="last_name"&gt;&lt;br>

  &lt;input type="submit" name="submit" value="Update"&gt;

&lt;/form&gt;

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


Messages In This Thread
Form validation always returns false in all cases - by El Forum - 07-04-2012, 11:40 AM
Form validation always returns false in all cases - by El Forum - 07-04-2012, 02:11 PM
Form validation always returns false in all cases - by El Forum - 07-04-2012, 02:45 PM
Form validation always returns false in all cases - by El Forum - 07-04-2012, 03:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB