0
votes

I'm searching a way to show custom message declared on validation array inside a notEmpty rule. So if i have this validation:

'username' => array(
        'notEmpty' => array(
            'rule' => 'notEmpty',
            'message' => 'username empty',
            'required' => true
        ),
        //other validation rules

if i leave e filed empty into form, cake php show his own default message for empty field, and not my custom message. How can i show it and catch this event into my Controller class?

1

1 Answers

1
votes

The key to the array should be the fieldname, unless I'm misunderstanding your context:

'myFieldName' => array(
           'rule' => 'notEmpty',
           'message' => 'custom message for empty field',
           'required' => true
       )

If I've misunderstood the context, please edit your question giving a little bigger picture of the validation code in your model.