CakePHP通知(8)提出:使用未定义的常量inList - 假设'inList'

Notice (8): Use of undefined constant inList - assumed 'inList' [CORE\Cake\Utility\ClassRegistry.php, line 168]

This notice has been bugging me for a while know, and I do not know how to fix it.. It was not really affecting my project earlier since its just a notice msg, but now, it is not letting me show an error message which I am trying to display to the user.

Iv got this function

  public function validate_form(){
        if($this->RequestHandler->isAjax()){
            $this->request->data['Donor'][$this->params['form']['field']] = $this->params['form']['value'];
            $this->Donor->set($this->data);
            if($this->Donor->validates()){
                $this->autoRender = FALSE;
            }else{
                $error = $this->Donor->validationErrors;
                $this->set('error',$error[$this->params['form']['field']]);           

            }
        }
    }

The above is the action to which my post request submits to. Then it executes the following to display the error

 if (error.length > 0) {
     if ($('#name-notEmpty').length == 0) {
      $('#DonorName').after('<div id="name-notEmpty" class="error-message">' + error + '</div>');
     }
 }else{
    $('#name-notEmpty').remove();
 }

The problem is that instead of the relevant error in my newly created div... I get that notice 8 from cake! Please if anyone knows why this is happening, I appreciate your aid on this one..

TLDR:

Do a project-wide find for 'inList' and find the spot where it either doesn't have quotes around it, or, if it's supposed to be a variable, is missing it's $.

Explanation:

You get that error when you try to use a PHP Constant that doesn't exist. Usually you're not actually TRYING to use a constant, but instead just forgot to wrap quotes around something or forgot to add the $ before a variable.

Examples:

$name = "Dave";
echo name; // <-- WOAH THERE, there is no Constant called name (missing $)

$people = array('Dave' => 'loves pizza');
echo $people[Dave]; // <-- WOAH THERE, no Constant called Dave (missing quotes)

Most likely somewhere else in your code you are using 'inList' as an array key but you don't have it quoted.

Example: $value = $myArray[inList];

It still works without quoting inList but it causes the notice message you're seeing.