0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

i've edited my question. I've only extract the portion of validation rule about not empty field, because my field has multiple rules
Try with required => false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.