开发者

CakePHP - Manipulating data-Attribute in validation process

I am trying to manipulate the $this->data attribute while performing an advanced validation method. The data seems to be changing, but when it comes to saving, the changes do开发者_StackOverflown't apply.

My question: Am I able do edit $this->data while performing a validation method?

Best regards, Benedikt


Most objects in CakePHP have a data property including the model, view and controller objects. Submitting a form from the view, means the data submitted will be available in $this->data in your controller action. When you call $this->Model->save($this->data) in your controller action, CakePHP copies the data passed in here to the data property of your model, and will then perform the validation on that array. If you are doing this, then any validation rule in this model should be able to affect the data property of the model. If this explanation doesn't help you figure out your problem, post more information so we can better understand what you're trying to do.


You might need to

$this->YourModel->create()

if you're not doing so already.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜