Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:30:36+00:00 2026-05-30T17:30:36+00:00

I have a custom function to validate a field, but when i test it

  • 0

I have a custom function to validate a field, but when i test it I have this error from 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

this is my code but I can’t see the problem…if I remove the callback it work well

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;
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:30:38+00:00Added an answer on May 30, 2026 at 5:30 pm

    I think your function should be named like the standard CI form validation callbacks, IE,

    public function controllo_esistenza($str)
    {
       if($str=="test")
       {
         return FALSE;
       }
    }
    

    Although I would do this:

    $this->form_validation->set_rules('nome','Nome','trim|required|callback__controllo_esistenza');
    

    And then this:

    public function _controllo_esistenza($str)
    {
       if($str=="test")
       {
         return FALSE;
       }
    }
    

    So your callbacks don’t somehow get called via the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my model I have: validate :my_custom_validation def my_custom_validation errors.add_to_base(error message) if condition.exists? end
I know this has been asked a lot, but I have a server-side custom
I have a custom validation function in JavaScript in a user control on a
i have custom cell with 2 buttons(the function of these buttons is just to
I have a custom UITableViewCell. In its function - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier, I need
I have a load of php templates which uses a custom translate function __,
I have a custom control that has the following prototype. Type.registerNamespace('Demo'); Demo.CustomTextBox = function(element)
I have a function which takes a custom struct as the argument. how can
I have used sendinput() function and windows keyboard hooks to develop a custom keyboard
I have custom errors configured in my web.config, but IIS 6.0 is returning the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.