In form element, I have edited error messages:
$this->addElement('text', 'type', array(
'label' => 'Type: ',
'class' => 'form-control',
'placeholder' => 'type',
'required' => true,
'validators' => array(
array('validator' => 'StringLength', 'options' => array('min' => 3, 'max' => 10, 'messages' => array('stringLengthTooShort' => 'The type is too short.', 'stringLengthTooLong' => 'The type is too long.')))
,array('validator' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Type is required.')))
),
));
Problem is, if I send empty form, both messages will show up (The type is too short + Type is required.). But in this case, I need to show up only NotEmpty error message and not Stringlength (min length 3) error message. So I need to validate minlength after NotEmpty validation. Thanks
EDIT: i have tried changing diferent positions of calling required and validators and diferent settings of their chains true/false (next code), but it still shows me both error messages if element is empty
$this->addElement('text', 'type', array(
'label' => 'Type: ',
'class' => 'form-control',
'placeholder' => 'type',
'validators' => array(
array('validator' => 'NotEmpty',true, 'options' => array('messages' => array('isEmpty' => 'Type is requiredDDDD.'))),
array('validator' => 'StringLength',false, 'options' => array('min' => 3, 'max' => 10, 'messages' => array('stringLengthTooShort' => 'The type is too short.', 'stringLengthTooLong' => 'The type is too long.')))
),
'required' => true,
));