phppyrocms

How to show the value of Select Field Type in PyroCMS's TableBuilder?


I have a field called type and it is a select field type. I see the values instead of the keys in select HTML element of the form builder but, in the table builder I only see the key as the not the values. It is clear that is how they are derived from the database but it there a setting to switch this? I don't want to hard code this. I read some related pages in the documents but could not find a configuration for this.

    protected $fields = [
        'type' => [
            'type' => 'anomaly.field_type.select',
            'config' => [
                'options'       => ['foo' => 'Foo', 'bar' => 'Bar'],
                'mode'          => 'dropdown'
            ]
        ]
    ];

Solution

  • Your table column value would look something like this:

    protected $columns = [ 'type', // Shows the KEY value for select field types 'entry.type.value', // Would show the label value for select field type ];

    Note that you can access presenter methods easily AND retain automatic field operations in columns by prefixing with entry..