CodeIgniter Forums
Double Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- 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:

Code:
$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

[eluser]tomcode[/eluser]
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.