use:
$this->Form->input('Model.id');
The default input will be hidden and if you're using the Security
Component (as you should!) it will be protected from tampering. That
way the ID of the editable record is within $this->data, regardless of
validation error or not. This kills two birds with one line.
Hope that helps,
Nick
On Jun 13, 11:55 pm, John Andersen <j.andersen...@gmail.com> wrote:
> I can't tell you why it happen, but I can tell you how I work with
> editing an existing record.
>
> When a record is chosen for editing, I store the record id in the
> session. Upon saving the record I take the id from the session. I
> don't rely on the record id being in the url. If I did that, then the
> user could easily change it upon submitting the form, which would be a
> bad thing :)
>
> Hope this helps you on the way,
> John
>
> On Jun 14, 3:34 am, Ed Propsner <crotchf...@gmail.com> wrote:
>
>
>
> > I notice that when I submit a form to a url such as
>
> >http://mysite.com/controller/action/25
>
> > If validation fails on the first attempt the form reloads under the exact
> > same url and retains all of $this->data
> > but if the validation fails on subsequent attempts the form reloads
> > but the record id gets dropped from the url and the only info left in
> > $this->data is the value
> > of the submitted form element and that's all.
>
> > What causes this? Is there a way around it?
>
> > - Ed
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment