Obviously, User model is not used in SupplierController, i.e. you're
missing the following
var $uses = array('User');
In your controller. That's why "Undefined property" error occurs when
you do $this->User.
Hope that helps!
On Feb 25, 3:27 pm, Matt <[email protected]> wrote:
> Hi all,
>
> I'm new to CakePHP (but not PHP) and I have followed the 5 part series
> by IBM to get me going on Cake PHP. I'm building a mini CMS for a
> client, and I am stuck... here's how the system should work:
>
> the client logs in and adds a supplier. The supplier is added to the
> database and has a field user_id which needs to automatically populate
> with the logged in user's id.
>
> My problem is that when I try to get the userid, I get the following
> error:
> Notice (8): Undefined property: SuppliersController::$User [APP/
> controllers/suppliers_controller.php, line 27]
> Fatal error: Call to a member function findByUsername() on a non-
> object in /var/www/online_contractors/app/controllers/
> suppliers_controller.php on line 27
>
> In the supplier controller I attempt to fetch the userid as so:
>
> $results=$this->User->findByUsername($username);
> $this->set('user', $results['User']);
>
> The username is what gets written to session when logged in.
>
> Any help would be greatly appreciated!
> Thanks!
> -Mathieu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---