post by mopac on Dec 18, 2025

I am porting an application from v2.0 Community to v3.2.6 Enterprise
callbackColumn() worked perfectly in v2.0 but in v3.2.6 it doesn’t seem to do anything.
Below is my test method

    public function test()
    {
        $crud = $this->_getGroceryCrudEnterprise();
        $crud->setTable('children');
        $crud->columns(['Child_first_name', 'Age']);
        $crud->fieldType('Age', 'virtual');
        $crud->callbackColumn('Age', function ($value, $row) {
            return "Hello";
        });        
        $output = $crud->render();
        return $this->_example_output($output);
    }

I would expect a table with 2 columns where the ‘Age’ column has ‘Hello’ in every row.
What I get is an empty column. I checked the HTML and the ‘Age’ column is definitely empty.

I added the $crud->fieldType(‘Age’, ‘virtual’); line because gc complained ‘Age’ wasn’t in the database.

What am I doing wrong?

post by mopac on Dec 20, 2025

OK. I Think I have the solution.
Instead of using ‘$crud->fieldType(‘Age’, ‘virtual’);’
Use '$crud->mapColumn(‘Age’,‘Child_first_name’);
Or just map the virtual column to any real column. Then callbackColumn produces results.

Johnny, maybe a note in the documentation for callbackColunm that says something about it not working for virtual columns. The workaround is to use mapColumn()

Ray

post by johnny on Dec 21, 2025

1 / 3
Dec 2025