Use a set_rules callback in a libraries |
You can extend CI_Form_validation and define new callbacks there.
Some notes about your implementation of MY_Form_validation. You do not need to add the property $CI. The parent class CI_Form_validation already has that property and it is accessible in the extending class. You don't need MY_Form_validation::__construct because it does not do anything besides call parent:: __construct. PHP will call the parent constructor without your help. In the new callback you don't have to find the instance of form_validation because you're in the instance you're looking for. All that said, your class should look like this. PHP Code: class MY_Form_validation extends CI_Form_validation As you stated, it would be used like this PHP Code: if($config_rules['images'] == true){ $this->form_validation->set_rules('images','images','require_upload');} Not sure why you have the callback always returning false. Maybe you're not done writing it yet? |
Messages In This Thread |
Use a set_rules callback in a libraries - by xenos92 - 11-28-2018, 08:15 AM
RE: Use a set_rules callback in a libraries - by jreklund - 11-28-2018, 01:26 PM
RE: Use a set_rules callback in a libraries - by InsiteFX - 11-28-2018, 01:47 PM
RE: Use a set_rules callback in a libraries - by dave friend - 11-28-2018, 04:43 PM
RE: Use a set_rules callback in a libraries - by dave friend - 11-28-2018, 04:50 PM
|