I feel so stupid, but I can’t understand how to assign data to the view (edit post form) in blog tutorial.
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html#editing-posts
public function edit($id = null) {
$this->Post->id = $id;
if ($this->request->is('get')) {
$this->request->data = $this->Post->read();
So this is assigning some data from database to request->data array, right?
But how view gets this data in form fields?
P.S. Why is null used as a default value in edit($id = null)?
Anything that you assign to $this->request->data in the controller will be available in your view as $this->data. If you use cakes built in form helper, it’s smart enough to check $this->data for variables that match the name of your form controls.