newbie question about model visibility

2007-08-16 Thread bill2520

Sorry to ask such a simple question, but I can't find where it is
explained.

I have two models:

User belongsTo Status
Status hasMany User

When I create a new user, I want to generate a select box to choose
the status.

users_controller.php:
class UsersController extends AppController
{
  var $name = 'Users';

  function add()
  {
$this-set('users', $this-User-findAll());
$this-set('statuschoices', $this-Status-generateList(
null, name ASC, null, {n}.Status.id,
{n}.Status.name)
);
  }
}

But, it can't resolve $this-Status
 It gives the message  Notice: Undefined property: UsersController::
$Status ...

(It is able to resolve $this-User.   I presume this is Cake
automagically instantiating the User object because I followed the
correct naming convention.)

How should I be doing this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: newbie question about model visibility

2007-08-16 Thread Grant Cox

var $uses = array('User',Status')

then you can use $this-Status.  Or, just use $this-User-Status (the
Status instance will be created on the User because of the
association).


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---