ECA Field Widget¶
Plugin ID: eca_field_widget_actions:eca_field_widget
Available since: 2.1.11
Provided tokens
| Token | Description |
|---|---|
[user] |
The current user. Alias: current_user |
[htmx] |
Information about the current HTMX request. |
[htmx:is_request] |
Whether the current request was sent by HTMX ("1" or "0"). |
[htmx:boosted] |
Whether the current request was boosted by HTMX ("1" or "0"). |
[htmx:history_restore] |
Whether the current request is for HTMX history restoration ("1" or "0"). |
[htmx:target] |
The identifier of the element the response is targeted at. |
[htmx:trigger] |
The identifier of the element that triggered the request. On Drupal 11 this is the element id, on Drupal 12 and later it is the CSS selector that htmx 4 sends. Prefer "trigger_name", which means the same thing on both. |
[htmx:trigger_name] |
The name attribute of the element that triggered the request, or empty if it has none. This has the same meaning on all supported Drupal versions. |
[htmx:source] |
The CSS selector of the element that triggered the request, for example button[name="first_item"]. Empty on Drupal 11, which does not send this information. |
[htmx:request_type] |
Whether the request targets a full page or a fragment: "full" or "partial". Empty on Drupal 11, which does not send this information. |
[htmx:current_url] |
The URL of the page the request was sent from. |
[entity] |
The entity being edited. |
[field_name] |
The name of the entity field for which the field widget is used. |
[field_key] |
The index of the field starting with zero and going up if it is a multi-value field. |
[event] |
The event. |
[event:machine_name] |
The machine name of the ECA event. |
[session_user] |
The user account that dispatched the event, regardless if ECA is processing models under a different account. This is only available if ECA is configured to always run under a specific account. |
Apart from the optional Restrict by widget kind setting, this event has no configuration options. However, you may want to at least give it a label because that's how it will be displayed in the form display configuration.
To get a field widget action from ECA work with form fields, you start with this event and the subsequent actions and conditions receive the above tokens with which you can build your process.
The
Set field widget value
action is the only way to return a value to the field widget. The [entity]
token holds an entity built from the current form state for reading only. That
entity is never saved, and it is never read again after the event, so setting a
field value on it has no effect on the form.
Restrict by widget kind
Left unrestricted, which is the default, the model is offered on every field widget. The first three choices, Editor / text fields, Select list and Checkboxes or radio buttons, are the shapes that the direct fill logic writes a value into. The fourth, Compound fields (Address, Link, Smart Date, ...), scopes the model to fields that store more than one property per item, which receive a mapping of their property names rather than a string. See Set field widget value for how to write that mapping.
One button fills one field
A field widget action can only ever fill the single field its button belongs to. The response addresses one selector, resolved from the position of the clicked button in the form, and a model has no way to address another field. To populate several fields from one interaction, use a Build form event with the Form field: set value action, or compute the values when the entity is saved.
Fields¶
Restrict by widget kind— config key:fill_strategies-
Leave unrestricted to offer this model on every field widget, which is the default. Otherwise pick the kind of widget this model produces a value for. The first three choices are the shapes the direct fill logic writes a value into; the last one offers the model on every field that stores more than one value per item, such as Address or Link. Widgets of another kind are left to the suggestions dialog.
Type:
select· Required: no · Default: empty stringAllowed values:
'',editor,select,buttons,compound