我有一个包含许多字段的表单,其中 2 个包含代码。我想验证代码不匹配。这些是元素:
'code1' => array('text', array(
'required' => true,
'label' => 'form-label-code-1',
'filters' => array('StringTrim'),
'attribs' => array('placeholder' => 'Code 1'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'div')),
'Errors'
),
'validators' => array(
array('Callback', true, array(
'callback' => array($cservice, 'checkCodesUsed'),
'messages' => array(
Zend_Validate_Callback::INVALID_VALUE => 'form-error-code-exists'
)))
)
)),
'code2' => array('text', array(
'required' => true,
'label' => 'form-label-code-2',
'filters' => array('StringTrim'),
'attribs' => array('placeholder' => 'Code 2'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'div')),
'Errors'
),
'validators' => array(
array('Callback', true, array(
'callback' => array($cservice, 'checkCodesUsed'),
'messages' => array(
Zend_Validate_Callback::INVALID_VALUE => 'form-error-code-exists'
)))
)
)),
当前回调仅检查数据库中是否已存在值。如何指定同时具有 code1 和 code2 值的回调?我似乎无法理解 zend 文档。