如何验证cakephp中模型的单个字段 [英] How to validate single field of a model in cakephp

查看:88
本文介绍了如何验证cakephp中模型的单个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为User的模型,它的$ validate有39个字段验证,在UsersController中工作正常。在另一个控制器中,我需要使用相同的代码,并且只验证控制器中的一个字段。 Areonce请帮我解决这个问题吗?

I have a model called User and its $validate has 39 field validations and working fine in UsersController. In another controller I need to use the same code and validate only a single field from controller. Can Someonce please help me with this?

推荐答案

相关文档

使用 c>

$this->ModelName->set($this->data);
if ($this->ModelName->validates(array('fieldList' => array('myField')))) {
    // If myField validated successfully...
}

这篇关于如何验证cakephp中模型的单个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆