Awesome I am going to try that now. I was also thinking since its
essentially the same view it should also be the same action. I could just
write a switch in the action that reads a hidden field in the form and then
process accordingly. Not very pretty but it should work.
 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of brian
Sent: Wednesday, March 04, 2009 12:12 AM
To: [email protected]
Subject: Re: Brain sprain


Actually, I just realised that you could call $this->setAction('view',
$user_id) instead of redirecting.

On Tue, Mar 3, 2009 at 11:42 PM, Steven Wright <[email protected]>
wrote:
>
> Well the only issue is that the client wants all the data and the add 
> device on the same view. There will possible be more mini forms as 
> well. I would prefer to break it up into logical chunks but its not my
call.
>
> Would AJAX get me out of this? If I only have to update a region of 
> the page its different than a redirect.
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On 
> Behalf Of brian
> Sent: Tuesday, March 03, 2009 9:17 PM
> To: [email protected]
> Subject: Re: Brain sprain
>
>
> On Tue, Mar 3, 2009 at 3:55 PM, RhythmicDevil 
> <[email protected]>
> wrote:
>>
>> Hi,
>> I am having a brain sprain. I have a controller Subscribers that has 
>> two actions 'view' and 'add_device'. View is called from the index 
>> page with a Subscriber ID and then shows all the Subscriber's details.
>> In the 'view' view there is a form to add a device. This form's 
>> action points at 'subscribers/add_device' and passes the 
>> subscriber_id and the device_id.
>>
>> If the device_id is empty I want to send the user back to the 'view'
>> view (I have to change that name) populated with the Subscriber's 
>> data. For some reason I cant figure out how to do that in a simple 
>> way. Because each call to a view is separate request the data does 
>> not persist. Would someone be so kind as to point out the obvious to me?
>
> Usually, the way this sort of thing is handled is to put the form in 
> the "add" view. This way, if the save fails, Cake can simply 
> re-display the form. If it succeeds, a redirect occurs.
>
> Would it be possible to put a regular link in the "view" view that 
> pointed to controller::add_device()? You could append the subscriber_id to
the URL.
> Or, you could use a hidden field in a form with a GET method.
>
> So, things would look something lie this:
>
> request:
> /subscribers/view/:id
>
> display:
> the subscriber's info, plus link/form to add device
>
> request:
> /subscribers/add_device/:id
>
> display:
> the form
>
> If the POST fails, you simply don't redirect and Cake will re-display 
> the same form, though with an error msg if you've set that up.
>
>
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to