• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic example of creating MY_Form_validation?

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.

If it's defined in your controller, then it's a callback, so you need to reflect that in your rule:
$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.

@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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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