Thursday, April 29, 2010

Re: Accessing data from controller in view

In the view?

If yes, I get this:

Notice (8): Undefined property:  View::$Profile [APP/views/profiles/edit.ctp, line 17]

Fatal error: Call to a member function value() on a non-object in /var/www/fotopoetica/app/views/profiles/edit.ctp on line 17


On Thu, Apr 29, 2010 at 5:17 PM, Jeremy Burns <jeremyburns@me.com> wrote:
Try: $this->Form->value('Model.field_name');

Jeremy Burns
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 29 Apr 2010, at 15:14, Andrei Mita wrote:

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

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

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: