2

When I post the form it shows error:

Trying to get property of non-object [APP\Controller\UsersController.php, line 647].

Here the ctp file form code:

admin_highlightedstylist.ctp is

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

Here the controller code script, 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'));


        }

How can I remove this error and how can I solve it?

4
  • 2
    what is the code on line 647? Commented Aug 5, 2014 at 8:15
  • 2
    If it is URGENT then why has it taken 26+ minutes to answer the question on the previous comment. Answer it or we are all going to ignore this question. Commented Aug 5, 2014 at 8:43
  • 1
    You could have just found that typo yourself. And would have saved a lot of minutes yourself this way.. It cannot be that urgent after all. Learn to debug code. Commented Aug 5, 2014 at 10:05
  • Voting to close as "simple typographical error" - if there are other close voters hereabouts, please consider casting the same. Commented Dec 15, 2015 at 8:39

1 Answer 1

2

Have you tried to actually read the error message and do you know what it means?

$this->requert vs $this->request

It is a simple typo. The error message is IMHO very clear, it tells you that you try to use an object that doesn't exist. Pretty easy to debug if you know that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.