开发者

CakePHP if form field invalidates then values aren't remembered

I'm using model based validation with CakePHP and if the field invalidates then the values aren't remem开发者_StackOverflow中文版bered in the form.

Is there a built in method/way to prevent this and have Cake remember the users entered values?


Are you redirecting? The easiest way I've found to do this is that, if the model doesn't validate, then allow the processing to drop through and display the same page as part of the answering request. As soon as you redirect, the errors are lost. As long as you're using the Form helper, it should pre-populate the form from the values in $this->data.

You didn't provide much in the way of detail, but hopefully I understood your question correctly.


It should remember the data wheter it validates or not. Are you using full names for your fields including the model? Like this:

echo $this->Form->input('Model.fieldname');

Rather than the "short" notation with just the fieldname, like:

echo $this->Form->input('fieldname');

That should work in pretty much any case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜