首页 > 解决方案 > 如何修复“_existsIn' => '此值不存在'” Cakephp

问题描述

保存功能仅在我删除 company_id 时有效,但当我将 company_id 带回时,调试显示“_existsIn' => '此值不存在'”

public function createForm(){
        $user = $this->Auth->user();
        $company_id = $user['company_id'];
        $form_title = $_POST['form_title'];
        $total_score = $_POST['total_score'];

        $form = $this->FieldCoachingForms->newEntity();
        if ($this->request->is('post')) {

            $form->title = $form_title;
            $form->deleted = 0;
            $form->company_id = $company_id;

            if($this->FieldCoachingForms->save($form)){
                $this->Flash->success(__('Field Coaching Form has been saved!'));
            }else{
                $this->Flash->error(__('Something Went Wrong'));
                debug($form->errors());
            }

        }

        exit();
    }

标签: cakephpormcakephp-3.x

解决方案


您可能在of中有一条existsIn规则,并且不存在具有 ID 的公司。buildRulesFieldCoachingModel$company_id


推荐阅读