嗨,我想将自定义消息添加到错误消息中。这是我的代码。它根本不起作用,请问如何检查此代码一次。
$this->add(array(
'name' => 'toname',
'type' => 'Zend\Form\Element\Text',
'attributes' => array(
'id' => 'toname',
'class' =>'toname',
'required' =>true,
'validators' => array(
array(
'name' =>'NotEmpty',
'options' => array(
'messages' => array(
\Zend\Validator\NotEmpty::IS_EMPTY => 'Please enter User Name!'
),
),
),
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 4,
'max' => 20,
'messages' => array(
'stringLengthTooShort' => 'Please enter User Name between 4 to 20 character!',
'stringLengthTooLong' => 'Please enter User Name between 4 to 20 character!'
),
),
),
),
),
));