Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

cakephp - cant find the error on save record in Cakephp4

I am trying to save a new record from form data in cakephp4. This code worked in cakephp3.2 and has been updated but doesnt work. My issue is that I just get returned false? I cant do much with a 'false' when i try to save . I tried getErrors on $tutor which wasnt recognized either. How do I find out where the error is?

    $tutor = $this->Tutors->newEmptyEntity();
            $tutor = $this->Tutors->patchEntity($tutor,$saveData,
                [
                    'associated' => [
                            'AvailabilityForTutors'=>["validate"=>false],
                            'AvailabilityForAssessments'=>["validate"=>false],
                            'Subjects'=>["validate"=>false]
                    ],
                    "validate"=>false
                ]);
            
            // debug($tutor);
              
            $tutor = $this->Tutors->save($tutor,[
                'validate' => false,
                'associated' => [
                    'AvailabilityForTutors',
                     'AvailabilityForAssessments',
                    'Subjects'
                ]
            ]);
        
             debug($tutor);//returns false? this doesnt tell me anything

 https://book.cakephp.org/4/en/orm/saving-data.html
question from:https://stackoverflow.com/questions/66056417/cant-find-the-error-on-save-record-in-cakephp4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I changed the return value on save and can test for errors

$result = $this->Tutors->save($NewTutor,[

I can get erros in NewTutor


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...