dpowhyh70416 2014-01-26 18:08
浏览 54
已采纳

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..

  • 写回答

2条回答 默认 最新

  • douju4594 2014-01-26 18:49
    关注

    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)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)