Editable column in columns.yaml

Hello,

So far i have render the form fields as static fields in the columns.yaml config.

I am wondering if there is a way to add a field like a status toggle so user can toggle it without going to the model update itself.

Thanks in advance.

With a little help from our friends: List Switch plugin - October CMS

1 Like

@Eoler thanks alot for the plugin link.

You are right however i am asking for a toggle switch. The plugin works and the Icons are also there but i want to make a toggle switch like that in october cms.

Not sure what you mean with “make a toggle switch like that in october cms”, but if you dont like this list switch plugin, you can build custom switches with partials:

columns.yaml

    published:
        label: 'Publish'
        type: partial
        clickable: false

_published.htm partial

<div id="published_<?= $record->id ?>">
    <?= $record->getPublishedStatus() ?>

    <?php if ($record->published) : ?>
      <button data-request="onPublishDown" data-stripe-load-indicator data-request-data="checked[]: <?= $record->id ?>">
        Unpublish
      </button>
    <?php else : ?>
      <button data-request="onPublishUp" data-stripe-load-indicator data-request-data="checked[]: <?= $record->id ?>">
        Publish
      </button>
    <?php endif; ?>
</div>

=> getPublishedStatus returns the published status, nothing special…

And you need a handler for the onPublishDown and onPublishUp ofc. Basically you get the can use the same logic as for a handler which is triggered by a button in the toolbar, since the checked ids are added via data-request-data

Might not be the most pretty solution, but it worked for me. Feedback is welcome.

1 Like