• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Double Validation

[eluser]Matthew Lanham[/eluser]
I am about to run a test on this but just thought i'd ask and see if i get a response first, i have a callback that calls to a webservice and brings back any errors with data in addition to the errors on a form, but it is getting called too early in some cases, what i actually want to happen is it first checks the form data is ok, then if the validation is OK it then calls to the callback to check the web service validation....

So in my head i see it being something like:

$this->form_validation->set_error_delimiters('<li>', '</li>');
    $this->form_validation->set_rules('c_company_name', 'Collection Company Name', '');
    $this->form_validation->set_rules('c_full_name', 'Collection Contact Name', 'required');
    $this->form_validation->set_rules('c_telephone', 'Collection Contact Number', 'required');
    $this->form_validation->set_rules('c_email', 'Collection Email Address', 'valid_email');

    if ($this->form_validation->run() == TRUE)
        $this->form_validation->set_rules('nd_book', 'Booking', 'callback_book_nd');
        if ($this->form_validation->run() == TRUE)
            // Create booking

Would this work?

You should not run the validation twice, all previous defined rules will be checked again.

To run it twice You would need to extend the form_validation class with a reset method.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.