This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jasonwong
jasonwong

I defined a column that named 'disabled' in list_columns.yaml, and the database also has this field. but the value of this field is "Y" or "N" in the database, I want to display "Disabled" or "Enabled" in the table of list page, instead of "Y" or "N", and I would like to add extra HTML tag for the value, such as:

 <span class='label label-danger'>Disabled</span>

That look like better.

What is good idea? I tried a lot of ways will not work.

Thanks!!

jasonwong
jasonwong

I found a way that are defined the column type with 'partial' and use PHP script in specify file of column's path option.

Daniel81
Daniel81

Will something like this not work in your model:

// @return status
public function getDisabledAttribute()
{
    return ($this->disabled == 'N')
            ? 'Disabled'
            : 'Enabled';
}

?

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.