CodeIgniter Forums
Double Validation - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Double Validation (/thread-21818.html)

Double Validation - El Forum - 08-21-2009

[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?

Double Validation - El Forum - 08-21-2009

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.