Grocery CRUD Callback

0

I need to set a message for the user, after validating a callback function, however, I do not enter anything referring. It has a generic message that fits the entire form, I want it by fields.

I tried form_validation->set_message , but it did not work.

I appreciate if anyone knows how to display a custom message from a callback function.

    
asked by anonymous 09.11.2016 / 17:46

1 answer

0

An example:

 /** CHAMADA REGRA**/
   $this->form_validation->set_rules('campo', 'Label Campo', 'required', ['nome_regra', [$Objeto, 'nome_funcao_valida']]], 
            ['required' => 'Campo obrigatorio.']);


/** FUNCAO QUE VALIDA **/
function nome_funcao_valida($valor)
    {
     if(CONDICAO)
          return true;
    else
    {
       $this->form_validation->set_message('nome_regra', 'A {field} não confere');
                return false;
    }
}
    
11.11.2016 / 20:14