jimlab56999
jimlab56999

Hi,
I have My extending plugin for User Plugin. It works fine except extending backend List.
I get only column title but empty fields inside.

  public function boot()
    {
        UserModel::extend(function ($model) {
            $model->hasOne['profile'] = ['Eduard\Profile\Models\Profile'];
        });

        UsersController::extendFormFields(function ($form, $model, $context) {
            if (!$model instanceof UserModel) {
                return;
            }

            if (!$model->exists) {
                return;
            }

            // Ensures that a profile model always exxists ...
            ProfileModel::getFromUser($model);

            $form->addTabFields([
                'profile[headline]' => [
                    'label' => 'Headline',
                    'tab' => 'Profile',
                ],
                'profile[about_me]' => [
                    'label' => 'About_me',
                    'tab' => 'Profile',
                    'type' => 'textarea',
                    'searchable' => true,
                ],
            ]);
        });

        UsersController::extendListColumns(function ($list, $model) {
            if (!$model instanceof UserModel) {
                return;
            }

            $list->addColumns([
                'headline' => [
                    'label' => 'Headline',
                ],
            ]);
        });
    }
mjauvin
mjauvin

Did you add a database table migration to create the new field(s)?

jimlab56999
jimlab56999

Hi, yes
I can add data to My New Fields, save it.
I get new List heading in the backend, but all My New Fields is empty.

ps don`t now if I can add any printscreen here

mjauvin
mjauvin

in extendListColumns, shouldn't you be using, profile[headline] instead of headline

jimlab56999
jimlab56999

Yes this was an error

$list->addColumns([
                'profile[headline]' => [
                    'label' => 'Headline',
                ],

Thank you :)

Last updated

1-5 of 5