У меня есть пользовательская функция для проверки поля, но когда я проверяю это, у меня появляется эта ошибка от PyroCMS
:
Fatal error: Uncaught exception 'Exception' with message 'Undefined callback "$rule" in admin_razze' in /Applications/MAMP/htdocs/pyrocms/system/cms/libraries/MY_Form_validation.php:178 Stack trace: #0 /Applications/MAMP/htdocs/pyrocms/system/codeigniter/libraries/Form_validation.php(341): MY_Form_validation->_execute(Array, Array, 'test') #1 /Applications/MAMP/htdocs/pyrocms/addons/shared_addons/modules/canile/controllers/admin_razze.php(46): CI_Form_validation->run() #2 [internal function]: Admin_razze->nuovo() #3 /Applications/MAMP/htdocs/pyrocms/system/codeigniter/core/CodeIgniter.php(352): call_user_func_array(Array, Array) #4 /Applications/MAMP/htdocs/pyrocms/index.php(280): require_once('/Applications/M...') #5 {main} thrown in /Applications/MAMP/htdocs/pyrocms/system/cms/libraries/MY_Form_validation.php on line 178
это мой код, но я не вижу проблемы ... если я уберу обратный вызов, он будет работать хорошо
function nuovo(){
//Carico librerie e helper per la gestione del form
$this->load->helper('form');
$this->load->library('form_validation');
//Imposto le regole di validazione
$this->form_validation->set_rules('nome','Nome','trim|required|callback_controllo_esistenza');
$this->form_validation->set_rules('copertina','Immagine di copertina','trim|required|xss_clean');
if($this->form_validation->run() == FALSE){
$this->template->build('admin/razze/inserimento');
}
else{
//Recupero i campi e creo l'array per l'inserimento
$dati_insert = array(
'nome' => ucfirst($this->input->post('nome')),
'copertina' => $this->input->post('copertina')
);
//Carico il modello per salvare la razza
$this->load->model('gestione','',TRUE);
//Invio i dati al model
$this->gestione->salva_razza($dati_insert);
redirect('admin/canile/razze');
}
}
public function callback_controllo_esistenza($str){
if($str=="test"){
return FALSE;
}
}