gurucomkz/doubleselectrelation

Admin input with two selects

Installs: 1 355

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

v1.2.2 2023-10-25 20:33 UTC

This package is auto-updated.

Last update: 2024-12-04 01:59:58 UTC


README

Old-fashioned component with left column with available options, right column with selected ones and some buttons to move elements between those. Has filter fields to look up for the elements in the columns.

Installation

composer require gurucomkz/doubleselectrelation
composer vendor-expose

Usage

$offersList = Offers::get();
$offersSelector = DoubleSelectRelation::create('Offers', null, $offersList);
$fields->addFieldToTab('Root.Main', $offersSelector);

Select custom Title

Declare a field (i.e. LongTitle) or a getter (i.e. getLongTitle()) in your model and do like this:

DoubleSelectRelation::create('Offers', null, $offersList)
    ->setTitleField('LongTitle');

Enable preview

You may want to let users check out the options before working with them. It can be done like this:

DoubleSelectRelation::create('Offers', null, $offersList)
    ->setAllowPreview(true);

It will create a button in every line, which by clicking will display a readonly CMS form in a modal box.

Additionally, you can declare method getPreviewCMSFields() in your related model to make a totally custom preview form.

TODO

  • Checks for changes and reporting to the form to trigger "Save" button activation
  • Some API maybe for programmatic control over options?