This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jamiegrand
jamiegrand

Hi all,

Just watched Sam Georges video "Extending the User plugin" which has been a great help, but have hit a stumbling block which I am sure is simple but am hitting a brick wall at the moment so if any one out there can point me in the right direction....

the code below in the boot causing the following error "RainLab\User\Models\User must define a method getProfile[language]Options() " I have added getLanguageOption() to the language model not sure how to connect it to the user...

        'profile[language]' => [
          'label' => 'Languages',
            'tab' => 'Therapist',
            'type' => 'dropdown',
            'span' => 'right',
        ],
ndcisiv
ndcisiv

I came across this same problem. Curious if anyone has any ideas on it yet?

KurtJensen
KurtJensen

Running into same thing. My solution which will not work for everyone was to define my fields in the plugin.php as a PHP array and use PHP to create the options I need there instead of a YAML file.

 UsersController::extendFormFields(function($form, $model, $context){

            if (!$model instanceof UserModel)
                return;

            if (!$model->exists)
                return;

            if ($form->getContext() != 'update') return;
            if (!ProfileModel::getFromUser($form->model)) 
                return;

            // Flash::success($model->profile->created_at);
            // Ensure that a profile model always exists
            ProfileModel::getFromUser($model);

            $form->addTabFields([
            'moreinfo[somefield]' => [
                'label' => 'A Drop Down Field'),
                'comment' => 'This might be just the ticket'),
                'tab' => 'misc',
                'type' => dropdown,
                // You could also use a function to 
               // generate options array here
                'options' => [ 
                    'opt1'='Option One',
                    'opt2'='Option Two',
                    'opt3'='Option Three',
                    'opt4'='Option Four',
                    ],
                ],
                /**  MORE FIELDS HERE */
            ]);
        });

Incidently I am working on a fairly comprehensive extension to the user plugin that will add many fields to users. I have a few hurdles right now but hope to have it published next month.

Last updated

jamiegrand
jamiegrand

Thats pretty much how I resolved it...

'type'       => [
                'label'    => 'Type',
                'tab'      => 'Type',
                'type'     => 'dropdown',
                'options' => TypeModel::lists('name', 'id')
            ],

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.