This could possibly be the most difficult part to understand in 3.0 and may be subject to change if it turns out to be too complicated. All properties in the entities are protected by default against mass assignment, you need to modify your Article entity in order to let CakePHP know what properties can be assigned by newEntity:
On Wednesday, March 12, 2014 6:30:45 AM UTC+1, Dr. Tarique Sani wrote:
-- class Article extends Entity {
protected $_accessible = ['title' => true, 'body' => true];
}
or if you just don't care (not recommended):
class Article extends Entity {
protected $_accessible = ['*' => true];
}
The latter can be seen as a Eloquent::unguard();
On Wednesday, March 12, 2014 6:30:45 AM UTC+1, Dr. Tarique Sani wrote:
Wonder why saving is failingI am doing$article = $this->Articles->newEntity($this->request->data); if ($this->Articles->save($article)) { $this->Session->setFlash(__('Your article has been saved.')); return $this->redirect(['action' => 'index']);}$this->Session->setFlash(__('Unable to add your article.')); debug($this->request->data);gives['title' => 'Test Title','body' => 'This is the body']but debug($article);giveobject(Cake\ORM\Entity) {'new' => null,'accessible' => [],'properties' => [],'dirty' => [],'virtual' => [],'errors' => []}What can possibly be wrong. I am guessing the title and body should appear as properties of the newly created entity without which the saving will not happenI did a composer update just now - so I do have the latest code.CheersTarique--
============================================================ =
The Conference Schedule Creator : http://shdlr.com
PHP for E-Biz : http://sanisoft.com
============================================================ =
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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment