1. edit($id = null) will set the default value of $id to null if
nothing is passed into edit. If a value is passed to edit $id = null
will be ignored.
2. $this->Post->id = $id will assign the value of $id to the Post
model. If nothing is passed into edit() null will be assigned.
3. if(empty($this->data)) is checking the current form data. If data
is empty the form hasn't been submitted. $this->data =
$this->Post->read(); than pulls the Post data and assigns it to data
so the form can be populated with the current Post values for editing.



On Tue, Nov 24, 2009 at 4:58 PM, cakephp9 cakephp9 <[email protected]> wrote:
> I have some basic questions about the blog tutorial
>
> 1 What does edit($id = null) mean, is $id being reset tot null?
> 2 What does $this->Post->id = $id; then do, make it null too?
> 3 Why do we check again if the data is empty, the data validation
> prevents it from being empty?
>
> Thanks in advance!
>
> http://book.cakephp.org/view/340/Editing-Posts
>
> function edit($id = null) {
>        $this->Post->id = $id;
>        if (empty($this->data)) {
>                $this->data = $this->Post->read();
>        } else {
>                if ($this->Post->save($this->data)) {
>                        $this->Session->setFlash('Your post has been 
> updated.');
>                        $this->redirect(array('action' => 'index'));
>                }
>        }
> }
>
> 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 [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
>

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 [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