当我发布表单时,它显示错误:
Trying to get property of non-object [APP'Controller'UsersController.php, line 647].
下面是ctp文件格式代码:
admin_highlightedstylist。ctp是
<?php echo $this->Form->create('Userhighlighted'); ?>
<tr>
<th>STYLIST LIST</th>
<th><?php echo $this->Form->input('stylist_id', array('empty' => 'Select Stylist')); ?></th>
<th>
<div class="submit">
<?php echo $this->Form->end('ADD HIGHLIGHTED'); ?>
</div>
</th>
</tr>
这里是控制器代码脚本,UserController.php
public function admin_highlightedstylist(){
$this->layout = 'admin';
$this->isAdmin();
if($this->request->is('post')){
print_r($this->requert->data['Userhighlighted']['stylist_id']);
exit;
}
$stylists = $this->User->find('list', array('conditions'=>array('is_stylist' => true,)));
$this->set(compact('id', 'stylists'));
}
如何删除此错误以及如何解决此错误?
你试过实际阅读错误信息吗?你知道它是什么意思吗?
$this->requert
vs $this->request
这是一个简单的打字错误。错误信息非常清楚,它告诉您尝试使用不存在的对象。