'Octobercms Custom fields plugin for Rainlab.User show field in list

please, know anybody how to show my custom filed from Custom Fields plugin for Rainlab.User plugin in list of users in Rainlab.User in backend?

For example i have custom field "valid_to" and I need it in the list of users without go to user detail.

thank you

Vaclav

Update:

Hi, thank you i tried extend the User plugin by Custom Fields ( https://octobercms.com/plugin/pkurg-customfields )

/plugins/pkurg/customfields/Plugin.php

On the list /rainlab/user/users the field valid_to is showed, but is empty .

When i clicked to sort "Valid To" alert window is opened:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'valid_to' in 'order clause' (SQL: select users.* from users order by valid_to desc limit 20 offset 0)" on line 664 of /www/doc/www.flexiqr.cz/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php

valid_to field is on the other table than users, is in pkurg_customfields_... right?

Thank you

Vaclav



Solution 1:[1]

It's easy you can simply extend UsersController and add your column using extendListColumns function.

Ref : How To Add New Column In October Cms List

<?php namespace HardikSatasiya\SO;

use System\Classes\PluginBase;


use RainLab\User\Controllers\Users as UsersController;
use RainLab\User\Models\User;

class Plugin extends PluginBase
{
    public function boot() {
        
        // extending Controller which has ListController Behavior 
        UsersController::extendListColumns(function($list, $model) {
        
            // we want only our User model be extended
            if (!$model instanceof User) {
                return;
            }
    
            // adding valid_to column
            $list->addColumns([
                'valid_to' => [
                    'label' => 'Valid To',
                    'type' => 'text', // or 'date'
                    'searchable' => true
                ]
            ]);
    
        });
    }

You will be able to see that column in the backend in Rainlab.User record list.

if any doubt please comment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hardik Satasiya