【问题标题】:Validation not working with saveMany验证不适用于 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)

标签: cakephp cakephp-2.0


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-10-12
    • 2011-05-18
    • 2011-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    相关资源
    最近更新 更多