Dynamic Dropdown allows you to populate pimcore input fields with the content of other objcts.
or install it via composer on an existing pimcore installation
composer require thomas-keil/dynamic-dropdown
The plugin doesn't require any configuration but provides several input elements. These input fields can be configured like any other of pimcore's input elements.
The plugin extends pimcores class data compent menu in the section "Select". Four new elements can be used:
Dynamic Dropdown: a single select dropdown menu
Dynamic Dropdown (multiselect): a box with several items to select. Select one by clicking it, all other will be deselected. Hold the CTRL-key while clicking to add the item without deselecting the others.
Itemselector: the items are displayed in two columns, on the left are the available (or remaining) items, on the right are the selected ones. Transfer to the other column by doubleclicking or using the left/right arrow button. Up/down arrow buttons arrange the order.
Superbox Select: Like a "tag field". Select one item and it get's displayed, click the little "x" next to it to remove it.
The options for all input elements are the same, only the way the information is presented differes.
Following options need to be set:
The Dynamic Dropdown is the "classic" version of the provided input elements: a dropdown input field (ExtJS: Combobox). Every option is provided by an object in a configured folder, by a configured method. The folder can have nested subfolders, but only one type of object class can provide the data.
This input element extends pimcore's href element. Programatically, you can set it's value with the API like you'd do with a href.
The multiselect Dynamic Dropdown is like the single select version, but you can select more than one item. It uses ExtJS' UX MultiSelect. It extends pimcore's multiselection. Setting it with the API is like working with a multiselection.
The Itemselector is like the Multiselect, but uses the ItemSelector as UI element.
The SuperboxSelect is like the Multiselect, but uses the TagField as UI element.
use Pimcore\Model\Object;
$myHrefElement = Document::getById(23);
$myOtherHrefElement = Document::getById(23);
$myMultihrefElements[] = $myHrefElement;
$myMultihrefElements[] = $myOtherHrefElement;
$myObjectsElements[] = Object\Product::getById(98);
$myObjectsElements[] = Object\Product::getById(99);
$object->setDynamicDropdown($myHrefElement);
$object->setDynamicDropdownMultiple($myMultihrefElements);
$object->setItemselector($myMultihrefElements);
$object->setSuperboxSelect($myMultihrefElements);
$object->save();