On 20 ago, 15:09, carl67lp <ccander...@gmail.com> wrote:
> I've attempted to search this group for this particular issue, both
> from within the Groups interface and Google itself, but I can't seem
> to find what I need...so with luck, I'll get more success asking
> directly here.
>
> The issue is this: I have an "add" controller (model is Order), on
> which I've attached a URL parameter--a single number.  Thus, the URL
> is something like /sitevisit/orders/add/1.  This corresponds to adding
> an order for the visit that is ID = 1.  So far, everything works
> splendidly if I fill in the details correctly; in other words, if I
> provide valid data.
>
> Unfortunately, when I try to submit bad data (failing validation rules
> like email, phone, or notempty), I lose that URL parameter--and the
> form/view is no longer properly stocked.
>
> How do I retain that parameter even on failed submission?

By submitting the form to the current url.

>
> I tried this line (from some Google result I got):
>
> echo $form->input('id', array('type' => 'hidden', 'value' => $visitInfo
> ['Visit']['id']));
>
> which outputs this:
>
> <input type="hidden" name="data[Order][id]" value="1" id="OrderId" />
>
> but that doesn't seem to be what I want.  Plus, it's not really the
> order ID; it's really the visit ID, and should only be in the URL.

It is however exactly what you asked for ('id' means field id, you
gave no model so it'll use the default/current model. Therefore
Order.id).

>
> Any thoughts?  I'm most appreciative of some timely help!

echo $form->create('Order', array('url' => ....

if you want to be defensive you can use 'url' => $this->params['url']
['url']

hth,

AD
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to