dongxin9759 2010-09-08 21:28
浏览 20
已采纳

在CakePHP表单/模型上的自定义验证中使用核心验证?

Using CakePHP 1.3

I understand the example at http://book.cakephp.org/complete/1143/Data-Validation#Adding-your-own-Validation-Methods-1181 on how to add my own validation methods, but maybe I'm missing something.

I only want to validate that Field_B is 'numeric' (a core validation) if Field_A (a select/option) is equal to a certain value.

It seems that I'm supposed to add a custom validation, and then I check the values of other fields with $this->data, but how do I call on a built-in validation from within a custom validation function? Or am I doing it wrong?

  • 写回答

1条回答 默认 最新

  • doupeng8419 2010-09-08 21:47
    关注

    Validation::numeric($this->data['field'])

    Validation class (validation.php) is located in cake/cake/libs and you can see the available methods by inspecting the file (they're the same as the ones you pass to the validation array).

    Validation methods return true if validation passes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题