Thursday, April 29, 2010

Accessing data from controller in view

Hello,

In a basic CRUD application I have a user's profile edit page.
When /profiles/edit/4 page is accessed the action in the controller checks if an id is passed, then if I have some data to be saved.
If the id is present but no data, it reads the id related data and then pass it to a view like this:
$this->data = $this->Profile->read(null, $id);

The view is a basic form with lots of echo $form->input('field');

My question is: how can I access the data sent from the controller?

For instance, I want to write a the top of my view: Modifying profile for $data['name']

Do I have to put in my controller: $this->set('profile', $this->Profile->read(null, $id)); ??

Thanks

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: