验证不适用于 saveMany
Posted
技术标签:
【中文标题】验证不适用于 saveMany【英文标题】:Validation not working with saveMany 【发布时间】:2014-02-01 09:51:15 【问题描述】:验证不适用于所有值的 saveMany。它仅适用于第一个值。我正在使用翻译行为。
我的代码:
public function admin_add()
if ($this->request->is('post'))
$this->FaqCategory->create();
$this->request->data['FaqCategory']['name'] = Inflector::slug($this->request->data['FaqCategory']['name'], $replacement = '-');
if ($this->FaqCategory->saveMany($this->request->data))
$this->Session->setFlash('The faq category has been saved', 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));
else
$this->Session->setFlash(__('The faq category could not be saved. Please, try again.'));
$languages = $this->Language->getlangs();
$this->set('langs', $languages);
【问题讨论】:
有什么错误吗?如果有,请在这里发布。你能把$this->request->data dump 使用 $this->set($this->request->data) 【参考方案1】:试试这个:$this->FaqCategory->saveMany($this->request->data, array('validate' => true));
【讨论】:
以上是关于验证不适用于 saveMany的主要内容,如果未能解决你的问题,请参考以下文章