This is a generic Craft CMS plugin
ElementOptions fieldtypes function similar to the native Checkboxes fieldtypes, with the addition of a selected element to each option. Each element type is supported with it's own fieldtype: Assets, Users, Entries, and Categories., (*1)
, (*2)
The intital need for this plugin was to create a "layout selection" field. While a radio buttons field would do the trick, we wanted to be able to show a selectable image instead of a checkbox and text., (*3)
The most applicable element type is Assets, as it allows you to create a field where users can select from a pre-defined set of Assets., (*4)
, (*5)
composer require timkelty/craft-elementoptions
git clone https://github.com/timkelty/craft-elementoptions.git craft/plugins/elementoptions
craft/plugins/elementoptions
directoryElementOptions works on Craft 2.4.x and Craft 2.5.x., (*6)
, (*7)
See Craft Docs for Checkboxes Fields / Settings., (*8)
{title}
or {slug}
. This can be useful if you want the label/value to change with element, and vice-versa.See Craft Docs for Checkboxes Fields / Templating., (*9)
option.element
is available. It will return an ElementCriteriaModel
.<ul> {% for option in entry.elementOptionsFieldHandle %} <li>{{ option.element.first().title }}</li> {% endfor %} </ul>