Welcome Guest, Not a member yet? Register   Sign In
Basic example of creating MY_Form_validation?
#1

[eluser]Unknown[/eluser]
Can someone give me a basic example of the MY_Form_validation extension.

$this->form_validation->set_rules('financing', 'Financing Option', 'required|financing_test');
^^In my controller but it does no seem to find financing_test which is in MY_Form_validation. I think I am missing something in my controller that helps get to the function.
#2

[eluser]TheFuzzy0ne[/eluser]
If it's defined in your controller, then it's a callback, so you need to reflect that in your rule:
Code:
$this->form_validation->set_rules(‘financing’, ‘Financing Option’, ‘required|callback_financing_test’);

Alternatively, you could extend the validation library, and put your method in there. That way you won't need the 'callback_' prefix. I think you can also use helper functions too.
#3

[eluser]CroNiX[/eluser]
@TheFuzzyOne - I think you missed that he already has an extended validation library and is setting the rules in the controller.

@patricks031 - Where did you put your MY_Form_validation.php file? It should be in /application/libraries/MY_Form_validation.php and then when you load the form_validation library (normally) it will automatically load the extended version, if present. Also make sure the filenames and classnames are capitalized correctly.

It would be helpful if you posted your MY_Form_validation.php code.




Theme © iAndrew 2016 - Forum software by © MyBB