ActionColumn urlCreator/template

hello,
When Gii creates the CRUD files for a model, it typically creates an ActionColumn in the Gridview widget. Something like:

[
     'class' => ActionColumn::className(),
     'urlCreator' => function ($action, Colour $model, $key, $index, $column) {
         return Url::toRoute([$action, '_id' => $model->_id]);
     }
],

In this model, the table definition is:


CREATE TABLE public._colour (
    _id smallint NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 201),
    _name public.citext NOT NULL,
    CONSTRAINT _colour_pk PRIMARY KEY (_id),
    CONSTRAINT _colour_name_uk UNIQUE (_name)
);

The above ActionColumn definition (correctly) creates/derives URLs like: /colour/view?_id=201.

In The Yii Book (p272/273), the author configures the ActionColumn using

'template' => '{update} {view}',

When I use this code, the URLs are like: /colour/view?id=201. The _ character is removed from the parameter name and I get Missing required parameters: _id .

I can’t work out why.Can anyone explain what’s happening?

TIA.

What a weird naming convention you have. I think that might be the way how parameter names are converted to column names. Something that removes _ but I’m not sure. Is that possible to change names in the database?

Yup, that’s it. In fact there are a number of differences. Sigh. The naming convention avoids clashes with postgresql and sql keywords, which was giving me a headache. Then I ran into clashes with PHP keywords with some table names…I’ll have a think about how I can overcome that. Looks like a prefix might be in order.

Conclusion, anyway, points to table/column names.

Thanks for responding.