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

LMBdev
LMBdev

I would like to implement a list into backend controller for my users under a new tab.

https://ibb.co/fkAWFR (Add Tab Field)


UsersController::extendFormFields(function($form, $model, $context){
            if (!$model instanceof UserModel)
                return;
            if (!$model->exists)
                return;
            $form->addTabFields([
                'activity' => [
                    'tab' => 'Activity',
                    'type'  => 'partial',
                    'path' => '$/acme/plugin/controllers/viewedjobs/_viewed_jobs.htm'
                ]
            ]);
        });

https://ibb.co/ktHdvR (include this list)

My _viewed_jobs.htm partial looks like this: <?= $this->listRender() ?>

Which throws an error about list behavior not being initialized. After some looking I found these posts: https://octobercms.com/forum/post/listcontroller-error-need-help

So I added

$this->asExtension('ListController')->index()

to the partial and now it displays my user list controller.

I would like to display a list for my ViewedJobs controller. I also watched the tutorial here: https://octobercms.com/support/article/ob-21 to create my list manually, however, the variables are not defined when I use this code.

I also tried creating a new list config under the Users plugin (which I know is not a best practice) but it throws and error about groups() method not found.

Last updated

LMBdev
LMBdev

I went with a work around on this one and implemented a relation manager.


UsersController::extend(function($controller){         
            // Splice in configuration safely
            $myConfigPath = '$/acme/plugin/controllers/ControllerName/config_relation.yaml';

            $controller->relationConfig = $controller->mergeConfig(
                $controller->relationConfig,
                $myConfigPath
            );
        });

The partial used in the addTabField() function becomes:


     = $this->relationRender('viewedJobs') ?>

Last updated

1-2 of 2

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