Good point.. [?]

On Tue, Mar 31, 2015 at 2:28 AM, Dave Edwards <[email protected]>
wrote:

> Thanks for the reply.
>
> In that case not only is the blog tutorial wrong, but the manual is
> misleading as well.
>
> In http://book.cakephp.org/3.0/en/orm/saving-data.html patchEntity is not
> introduced until the section 'Merging Request Data Into Entities' at which
> point it has moved on from explaining how to save data to updating it.
>
> Dave
>
>
> On Monday, 30 March 2015 09:16:50 UTC+1, euromark wrote:
>>
>> no, patchEntity is what it is: it patches data into the entity
>> that is necessary for ALL forms, so both add and edit ones of course.
>>
>>
>> Am Sonntag, 29. März 2015 21:15:28 UTC+2 schrieb Dave Edwards:
>>>
>>> Why has the first method (which is the correct one) got both
>>>
>>> $this->Articles->newEntity()
>>>
>>> and
>>>
>>>  $this->Articles->patchEntity()
>>>
>>> when you are saving a new record?
>>>
>>> I thought that newEntity was used when inserting new data, and
>>> patchEntity was for updating existing data? Is my understanding incorrect?
>>>
>>> Dave
>>>
>>> On Friday, 27 March 2015 21:24:38 UTC, euromark wrote:
>>>
>>> The latter is deprecated, this changed during RC and as such the
>>> tutorial needs some updating.
>>> Thats all there is to it :)
>>>
>>> Mark
>>>
>>>
>>> Am Freitag, 27. März 2015 15:37:26 UTC+1 schrieb Bayezid Alam:
>>>
>>> Hi,
>>>
>>> A confusion comes on my mind regarding the adding something on CakePHP
>>> 3.0
>>>
>>> As example given on below link's in the add function.
>>> http://book.cakephp.org/3.0/en/tutorials-and-examples/
>>> blog/part-two.html#adding-articles
>>>
>>> public function add()
>>>     {
>>>         $article = $this->Articles->newEntity(); // *A blank newEnttity 
>>> added stored in $article variable*
>>>         if ($this->request->is('post')) {
>>>             $article = $this->Articles->patchEntity($article, 
>>> $this->request->data); // *A patchEntity added here & passed the request 
>>> data here*
>>>             if ($this->Articles->save($article)) {
>>>                 $this->Flash->success(__('Your article has been saved.'));
>>>                 return $this->redirect(['action' => 'index']);
>>>             }
>>>             $this->Flash->error(__('Unable to add your article.'));
>>>         }
>>>         $this->set('article', $article);
>>>     }
>>>
>>>
>>>
>>> But i found a different things on below link
>>> http://book.cakephp.org/3.0/en/tutorials-and-examples/
>>> blog-auth-example/auth.html#creating-all-user-related-code
>>>
>>> public function add()
>>>     {
>>>         $user = $this->Users->newEntity($this->request->data); // *request 
>>> data passing through newEntity here*
>>>         if ($this->request->is('post')) {
>>>             if ($this->Users->save($user)) {
>>>                 $this->Flash->success(__('The user has been saved.'
>>>
>>> ...
>>
>>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to