如何修复“ _existsIn'=>'此值不存在'” Cakephp

问题描述 投票:0回答:1

仅当我删除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();
    }
cakephp orm cakephp-3.x
1个回答
0
投票
[您可能在existsInbuildRules中有一个FieldCoachingModel规则,但ID为$company_id的公司不存在。
© www.soinside.com 2019 - 2024. All rights reserved.