is it possible to create a new type in laravel (eg. in columns.yaml)

55 Views Asked by At

Is it possible to add type in laravel/OctoberCMS?

columns:
    field:
        value: field
        type: specialdate

I'd like to have specialtype in backend (colors depends on value or some text instead of exact value (e.g. ZERO instead of 0 ;D

2

There are 2 best solutions below

0
Hardik Satasiya On

You can use a partial type of column to show what ever you want to show in columns

Ref: https://docs.octobercms.com/1.x/backend/lists.html#partial

0
mgrueter On

There are a few possibilities:

You can use the "Custom Value Selection" method described here: https://docs.octobercms.com/2.x/backend/lists.html#custom-value-selection. You can simply add an accessor to your model and use that as the display value.

You could also use the partial field type to display whatever you want in the column: https://docs.octobercms.com/2.x/backend/lists.html#partial

Those methods are best used for singular cases and custom implementation.

The best method for configurable columns would be creating a custom column type as described here: https://docs.octobercms.com/2.x/backend/lists.html#custom-column-types. Fairly straight-forward.

All the links are for OctoberCMS V2, but everything is also possible with V3. I am not sure about V1.