如何在 zend 中发送字段名称以进行所需的真实验证
How to send field name for required true validation in zend
这是我的表单域,
$this->addElement( 'text', 'title', array(
'placeholder' => 'Title',
'class' => 'form-control',
'required' => true,
'filters' => array( 'StringTrim' ),
'autocomplete' => 'off',
) );
我只需要如下错误字符串:
标题为必填项,不能为空。
试试这个:-
$this->addElement( 'text', 'title', array(
'placeholder' => 'Title',
'class' => 'form-control',
'required' => true,
'filters' => array( 'StringTrim' ),
'autocomplete' => 'off',
'validators' => array(
array('NotEmpty', false, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Title is required and cant be empty')))
)
) );
这是我的表单域,
$this->addElement( 'text', 'title', array(
'placeholder' => 'Title',
'class' => 'form-control',
'required' => true,
'filters' => array( 'StringTrim' ),
'autocomplete' => 'off',
) );
我只需要如下错误字符串: 标题为必填项,不能为空。
试试这个:-
$this->addElement( 'text', 'title', array(
'placeholder' => 'Title',
'class' => 'form-control',
'required' => true,
'filters' => array( 'StringTrim' ),
'autocomplete' => 'off',
'validators' => array(
array('NotEmpty', false, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Title is required and cant be empty')))
)
) );