Plugin form element provides two Form API elements — plugin and plugins — that let developers embed plugin configuration forms directly inside any Drupal form.
The plugin element renders the configuration form for a single pre-selected plugin (e.g. one condition, one action). The plugins element provides a full multi-item UI backed by vertical tabs, where users can add, configure, and remove multiple plugins from any plugin manager — with optional cardinality limits and allowlists.
Features
#type => 'plugin'— renders the configuration form for a single plugin instance#type => 'plugins'— multi-item UI with vertical tabs, AJAX add/remove, and form submission handling- Works with any plugin manager implementing
PluginManagerInterface - Supports
FilteredPluginManagerInterfacefor context-aware plugin filtering #cardinalityproperty to limit how many plugins can be added#allowed_pluginsproperty to restrict which plugins appear in the Add menu- Full compatibility with
PluginFormInterfaceandPluginWithFormsInterface
Usage
Configure a single plugin whose ID you already know:
$form['condition'] = [
'#type' => 'plugin',
'#title' => $this->t('Condition'),
'#plugin_manager' => 'plugin.manager.condition',
'#default_value' => [
'id' => 'language',
'langcodes' => ['en' => 'en'],
],
];Let users pick and configure multiple plugins from any manager:
$form['conditions'] = [
'#type' => 'plugins',
'#title' => $this->t('Conditions'),
'#plugin_manager' => 'plugin.manager.condition',
'#cardinality' => -1, // -1 = unlimited
'#allowed_plugins' => ['language', 'request_path'], // optional allowlist
'#default_value' => $saved_config, // keyed by UUID
];On submit, $form_state->getValue('conditions') returns a UUID-keyed array of plugin configurations — ready to store and reinstantiate.
Project information
- Project categories: Administration tools, Content editing experience, Developer tools
30 sites report using this module
- Created by hydra on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.



