Ad

How To Display 'Inactive/Active' For Switch Type In OctoberCMS List?

- 1 answer

I tried under format using this YAML syntax with Switch type or Text type

format: !e '%s == 0 ? Active : Inactive'

But doesn't work as expected. Is there anyway without modifying the controllers? How to display the word 'Inactive/Active' instead of 'Yes/No'?

Ad

Answer

You can try this:

First, create a partial for example _active_column.htm whit this content (as example):

<?php if($value){ ?>
    Active
<?php }else{ ?>
    Inactive
<?php } ?>

Then, in columns.yaml, you can invoke partial like this:

active:
    label   : Active
    type    : partial
    path    : ~/plugins/your/plugin/models/your_model/_active_column.htm

In this example, $value takes value of active column from Model.

Ad
source: stackoverflow.com
Ad