amici / craft-super-dynamic-fields
Use JSON templates as field options for dropdown, radio or checkboxes.
Package info
github.com/amici-infotech/craft-super-dynamic-fields
Type:craft-plugin
pkg:composer/amici/craft-super-dynamic-fields
Requires
- php: ^8.2
- craftcms/cms: ^5.0
README
Use a site Twig template that outputs JSON as the option source for Dropdown, Radio, Checkboxes, and Multi-select fields. Reuse one option list across many fields, generate options from Craft queries, and attach arbitrary per-option extras for Twig and GraphQL.
Requirements
- Craft CMS
^5.0 - PHP
^8.2
Installation
composer require amici/craft-super-dynamic-fields
In the Control Panel: Settings → Plugins → Super Dynamic Fields → Install.
Quick start
- Create a site template that outputs a JSON array (see JSON format).
- Create a field and choose one of:
- Dropdown [Super Dynamic Fields]
- Radio Buttons [Super Dynamic Fields]
- Checkboxes [Super Dynamic Fields]
- Multi-select [Super Dynamic Fields]
- Set JSON Template to your template path.
- Turn Cache options off if options depend on the current
element.
[
{"value": "", "label": "--"},
{"value": "option1", "label": "Option 1", "icon": "circle-check", "color": "#780d0d"},
{"value": "option2", "label": "Option 2", "icon": "@webroot/icons/abc.svg", "color": "red"}
]
{{ entry.myField.value }}
{{ entry.myField.label }}
{{ entry.myField.getIconHtml()|raw }}
{% set extras = entry.myField.getExtras() %}
{{ extras.class ?? '' }}
Documentation
- Installation
- Concepts
- JSON format (icons, optgroups, extras)
- Twig API
- GraphQL
- Events / PHP
- Native fields comparison
Upgrade notes
After updating to 5.1.0+, run migrations so stored field type class names are rewritten from the legacy SueprDynamic* spelling:
php craft migrate/all
Legacy class aliases remain so existing fields keep working until the migration runs.