Showing error message

Asked

Viewed 84 times

1

I made the following validations in Model:

class Inscricao extends AppModel
{
    public $name = 'Inscricao';
    public $useTable = 'inscricoes';

    public $validate = array(

        'nome' => array(
            'between' => array(
                'rule' => array('between', 5, 15),
            'message' => 'Entre 5 e 15 caracteres'
            ),
            'isUnique' => array(
                'rule' => 'isUnique',
            'message' => 'Nome já Cadastrado'
            )
        ),

The rules are working perfectly. In View I put the following:

                        $this->Form->input('nome',
                            [
                                'between'     => '<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>',
                                'type'        => 'text',
                                'class'       => 'form-control',
                                'placeholder' => 'Nome',
                                'required'    => false,
                                'label'       => false,
                                'div'         => false,
                                'error' => array(
                                    'between' => __('Minimo 5 Caracteres', true),
                                    'isUnique' => __('Nome já cadastrado', true)
                                    ),
                            ]);

But it doesn’t print even an error message.

In Controller I made that way the set:

class InscricoesController extends AppController
{
    public $name = 'Inscricoes';
    public $uses = array('Inscricao');

    public function add()
    {
        if($this->request->data)
        {
            if($this->Inscricao->save($this->request->data))
                $this->Session->setFlash('<b>Enviado com Sucesso!</b>');
                $this->redirect($this->referer());
        }
    }
}

When the data is valid it prints right the message 'Sent Successfully'.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.