Controlled Lists plugin, custom dynamic options in panel

Here’s another plugin no one asked for :wink:

This allows you to do stuff like this:

fields:
    mycheckboxes:
        label: Users
        type: controlledcheckboxes
        controller: MyPlugin::userlist

instead of:

fields:
    mycheckboxes:
        label: Users
        type: checkboxes
        options: 
            user: John Doe
            benutzer: Max Mustermann
            utente: Pinco Pallino
            #todo: please keep this list updated

where MyPlugin::userlist is a function you defined that returns the options to use in your checkboxes field.

8 Likes

I’ve tried this out and it’s a really simple and a really good plugin that I can recommend. :slight_smile:

In my case I used it to get companies (pages) from another folder.

Example

Blueprint

companylist:
  label: Company
  type: controlledselect
  controller: companylist::results

Static function

<?php
class companylist {
  static function results($field) {
    $result = array();
    foreach(page('companies')->children() as $company) {
      $result[$company->slug()] = $company->title();
    }
    return $result;
  }
}

It also matches my new workflow perfectly.

Great job @rasteiner!

Happy you like it! :slight_smile: