【问题标题】:Validating with Identical using value from another subform使用来自另一个子表单的值进行验证
【发布时间】:2012-01-18 18:33:27
【问题描述】:

我已经将一个长的一页表单分成了多个子表单,预计它将在项目生命周期的后期被拆分为一个多页表单。我在下面的 Identical 验证器中遇到了令牌 var 的问题。

来自 Application_Form 对象:

$authorizedIndividual = new Zend_Form_SubForm();
// .. authorizedName text element setup here

$termsAgree = new Zend_Form_SubForm();

// Add termsAgree
$termsAgree->addElement('text', 'termsAgree', array(
    'label'         => 'By typing your name in the preceding field, you, as the authorized individual agree to etc. etc. etc.',
    'class'         => 'termsAgree',
    'required'      => true,
    'filters'       => array('StringTrim'),
    'validators'    => array(
        array('validator' => 'Identical', true, $authorizedIndividual->authorizedName )
    )
));

【问题讨论】:

    标签: validation zend-form subform


    【解决方案1】:

    据我所知,Zend_Validate_Identical 仅适用于字符串标记。该值是通过此令牌从上下文(isValid 数据)中检索的。

    解决问题的最简单方法是在 isValid 方法中定义令牌,并改用 authorizedName 值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      • 1970-01-01
      • 1970-01-01
      • 2020-01-30
      相关资源
      最近更新 更多