1
幾年後,我剛剛烘烤了我的第一個測試項目,並且..我很困惑。未知的方法「saveAll」
public function add()
{
$post = $this->Posts->newEntity();
if ($this->request->is('post')) {
$post = $this->Posts->patchEntity($post, $this->request->getData());
if ($this->Posts->saveAll($post)) {
$this->Flash->success(__('The post has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The post could not be saved. Please, try again.'));
}
$parentPosts = $this->Posts->ParentPosts->find('list', ['limit' => 200]);
$this->set(compact('post', 'parentPosts'));
$this->set('_serialize', ['post']);
}
我提交表單後,我得到
未知法 「白水」
BadMethodCallException
所有我已經改變爲
$this->Posts->save($post)
(其中正常工作)到
$this->Posts->saveAll($post)
爲什麼此方法在此處未知?這與saveAssociated等相同。謝謝!