October CMS resources and help articles

Simple and to the point. Optimized by the community.

How to extend backend list columns and add custom column

2
by hardik_satasiya, last modified on March 22nd, 2022

You can add your custom column to existing backend list by extending controller with extendListColumns method.

make sure that controller has ListController behaviour implemented

class Plugin extends PluginBase
{
    public function boot() {

        // extending Controller which has ListController Behavior 
        Items::extendListColumns(function($list, $model) {

            // we want only our Item model be extended
            if (!$model instanceof Item) {
                return;
            }

            // adding quantity column or other new column
            $list->addColumns([
                'quantity' => [
                    'label' => 'Quantity',
                    'type' => 'number',
                    'searchable' => true
                ]
            ]);

        });
    }

You can add any type of column partial or relational columns.

Reference : How To Add New Column In October Cms List

It can be usefull when you need to show extended information with existing backend list or other 3rd party plugins.

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?