【问题标题】:Zend Validate PostCode in a Zend Form -> Validate depending on given countryZend 验证 Zend 表单中的邮政编码 -> 根据给定国家验证
【发布时间】:2011-05-13 13:25:45
【问题描述】:

如何根据同一表单中“国家/地区”字段中设置的国家/地区验证表单中的邮政编码字段?

我不知何故需要访问表单实例或另一个字段的值。有没有办法在回调验证器中做到这一点?

【问题讨论】:

    标签: php zend-framework forms validation


    【解决方案1】:

    查看此页面上的“验证上下文”注释 - http://framework.zend.com/manual/en/zend.form.elements.html(没有直接链接,只需 Ctrl+F Validation Context

    您可以在自定义验证器中使用$context 来访问其余提交的表单数据。

    【讨论】:

    • 谢谢!我通过添加一个执行 PostCode 检查的新类来修复它。你可以在这里看到它:gist.github.com/971363
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多