callbackColumn() has not effect in v3.2.6 Enterprise

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?

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

Hello @mopac and thanks for the update,

I have updated the documentation with this (check callbackColumn | Grocery CRUD - A PHP CRUD Generator Library ). I will keep a note though to see if I can implement the change on a future version. I remember it was a bit more tricky but worth a try.

Wishing you the best and a happy new year :slight_smile:

Regards
Johnny