try :

        $this->User->UserType->find('list',
array('fields'=>array('UserType.id', 'UserType.user_type')));

hth

On May 31, 9:39 am, tyler_durden <[EMAIL PROTECTED]> wrote:
> Hello, I'm a newbie with cakephp, I'm very interested on the
> framework, but I have a few days stucked on a very simple problem.
>
> I have a users table, user_types table (administrator, restricted,
> etc) and user_statuses table (active, suspended, banned, etc).
>
> I want to build the add new user form, this is what I've got this far:
>
> ***MODEL***
>
> class User extends AppModel
> {
>         var $name = 'User';
>
>         var $belongsTo = array(
>         'UserType' => array(
>             'className'    => 'UserType',
>             'foreignKey'    => 'user_type_id'
>         ),
>                 'UserStatus' => array(
>             'className'    => 'UserStatus',
>             'foreignKey'    => 'user_status_id',
>             'limit'        => '5'
>         )
>     );
>
> }
>
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> ***CONTROLLER***
> class UsersController extends AppController
> {
>         var $name = 'Users';
>
>         var $helpers = array('Form', 'Html', 'Javascript');
>
> function add() {
>                 if (!empty($this->data)) {
>                         if ($this->User->save($this->data)) {
>                                 $this->flash('New user has been 
> saved.','/users');
>                         }
>                 }
>                 /* HERE I TRY TO POPULATE THE DROPDOWN VALUES FOR USER TYPES*/
>                 $this->UserType->find('list', 
> array('fields'=>array('UserType.id',
> 'UserType.user_type')));
>         }
>
> }
>
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> ***VIEW***
> echo $form->create('User');
> echo $form->input('name');
> echo $form->input('last_name');
> echo 
> $form->select('user_type',array('vendor'=>'vendor','subcontractor'=>'subcontractor','employee'=>'employee'),'subcontractor',null,false);
>
> echo $form->end('Save Post');
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> When I try to load the page i get an error on the line that tries to
> populate the user types, this is the msg i get:
>
> Notice (8): Undefined property:  UsersController::$UserType [APP
> \controllers\users_controller.php, line 40]
>
> Code
>
>         }
>
>         $this->UserType->find('list',
> array('fields'=>array('UserType.id', 'UserType.user_type')));
>
> UsersController::add() - APP\controllers\users_controller.php, line 40
> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 268
> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 240
> [main] - APP\webroot\index.php, line 84
>
> Fatal error: Call to a member function find() on a non-object in \app
> \controllers\users_controller.php on line 40
>
> I'm sure this is a very basic task, but i've been unable to find the
> solution by myself, what am I doing wrong?
>
> Thanks a lot!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to