Welcome Guest, Not a member yet? Register   Sign In
non-parameter validation
#1

[eluser][email protected][/eluser]
Hello,

I tend to use the Validation for all of my form-validation and it works beautifully. However, how can I execute a custom method that is not related to a single parameter, yet still using the class?

ie.

i have a method called

function validateAlgorithmAmount($x, $y, $z){}

where $x, $y and $z are three different post parameters.

how can i call this function, and then on the front-end display when it fails???


thank you.
#2

[eluser]Pascal Kriete[/eluser]
You make it the last callback on the last validation rule of the three.
Code:
rules['x'] = trim|required|xss_clean;
rules['y'] = trim|required|sha1;
rules['z'] = trim|callback_checkParams;

....

function checkParams($z) {
    $x = $this->input->post('x');
    $y = $this->input->post('y');

    /* Do whatever */

    $this->validation->setMessage('checkParams', 'It's all broken.');
}

I use something like this for my login forms, with a checkCredentials callback, which then calls my auth library.




Theme © iAndrew 2016 - Forum software by © MyBB