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?

In reality I should probably do a validation on the client, but this
case would still have to be handled after a device is added. I would
want the user sent back to the 'view' view to see the updated data.

Thanks.
Steve


<?php
class SubscribersController extends AppController
{

        var $helpers = array('Html', 'Javascript');

        function index()
        {
                $this->pageTitle = 'Subscriber';
                $this->layout = 'default';
        }

        function view()
        {
                debug($this->data);
                if(! empty($this->data['Subscriber']['subscriber_id']))
                {
                        if(! $data = 
$this->Subscriber->fetchSubscriber($this->data
['Subscriber']['subscriber_id']))
                        {
                                $this->redirect('/subscribers/index'); // TODO 
no result handle
this!
                        }
                        $this->set('subscriber', $data);
                        $this->pageTitle = 'Subscriber';
                        $this->layout = 'default';
                }
                else
                {
                        $this->redirect('/subscribers/index');
                }


        }

        function add_device()
        {
                $this->autoRender = false;
                //debug($this->data);
                if(! empty($this->data['Subscriber']['device_id']))
                {
                        // handle adding the device
                        debug($this->data);

                        // Then reroute back to the view
                }
                else
                {
                        $this->redirect(array('controller' => 'subscribers', 
'action' =>
'view'));
                }

        }
}
?>
--~--~---------~--~----~------------~-------~--~----~
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