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 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?