验证无法与saveMany一起使用

时间:2014-02-01 09:51:15

标签: cakephp cakephp-2.0

对于所有值,验证不适用于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);
}

1 个答案:

答案 0 :(得分:0)

试试这个:$this->FaqCategory->saveMany($this->request->data, array('validate' => true));