CakePHP: Call to a member function find() on a non-object

前端 未结 2 1657
醉酒成梦
醉酒成梦 2021-01-22 16:33

I get the following errors when viewing my Admin Index

Notice (8): Undefined property: ClientsController::$Clients [APP/controllers/clients_controller.php, line          


        
相关标签:
2条回答
  • 2021-01-22 16:38

    Some potential issues:

    Normally

    var $name = 'Client'; // Not Clients
    

    You have a Client, and the controller is for "Clients".

    Try:

    $this->set('clients', $this->Client->find('all'));
    

    with the above suggestion on var $name.

    See a more complete list of potential solutions here if that doesn't lead you down the right path.

    CakePHP call to member function on non-object

    0 讨论(0)
  • 2021-01-22 16:51

    Model names are singular in CakePHP (at least if you follow the naming conventions), which means you have to use: $this->Client->find('all');

    0 讨论(0)
提交回复
热议问题