Reputation: 191
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
So how would i replace 1 with Yes?
Upvotes: 0
Views: 1510
Reputation: 76
You can also add 'context' attribute in columns.yaml file.
public:
label: Public
context:
1: Yes
0: No
Upvotes: 1
Reputation: 33
There is no need for partial in this particular case. It can be easily done in Builder.
It will display Yes/No for you automatically depending on column value (1/0)
Upvotes: 1
Reputation: 846
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
Upvotes: 0