OctoberCMS backend list value

- 1 answer

Ad

Is there a way to replace list value from 1 to Yes in backend form/list?

Example Database table entries

id - auto_increment
title - varchar
date - date
time - time
text - text
public - INT (1)

Now i created list in Builder which looks like this

List

So how would i replace 1 with Yes?

Ad

Answer

Ad

For this you need to create a partial for the column https://octobercms.com/docs/backend/lists#column-partial

Modify your myplugin/models/themodel/columns.yaml file for the public field

public:
    type: partial
    path: ~/plugins/yourname/myplugin/models/themodel/_content_column.htm

The content _content_column.htm file will be

<?php if ($record->public==1): ?>
 Yes
<?php else: ?>
No
<?php endif; ?>

or

<?php if ($value==1): ?>
 Yes
<?php else: ?>
No
<?php endif; ?>

$value is the default cell value, $record is the model used for the cell

Ad
source: stackoverflow.com
Ad