Set field widget value¶
Plugin ID: eca_set_field_widget_value
Available since: 1.0.0
This action sets the value for the field widget event.
The value this action produces is handed back to the field widget whose button dispatched the ECA Field Widget event. A single string covers text and editor widgets, and select lists, checkboxes or radio buttons receive a list of values or a comma-separated string.
Compound fields¶
A compound field, such as Address, Link, Smart Date, Date range or Custom Field, stores several properties per item, so a single string cannot fill it. Return a mapping of the field's property names instead:
- Enable Fill the field directly on the action button in Manage form display.
- Enable Interpret above value as YAML format in this action, and write one line per property into Field widget value.
For a link field:
1 2 | |
For an address field:
1 2 3 4 5 | |
A list of such mappings fills a multi-value field:
1 2 3 4 | |
The value is written onto the entity and the widget is then rebuilt from it, exactly as when an already saved entity is opened for editing. Any widget that can display a saved value therefore works, without the module knowing anything about the field type.
Finding the property names¶
Two sources answer which properties a field item stores:
- The item class of the field type.
LinkItem::propertyDefinitions()declaresuri,titleandoptions. - ECA's token browser, where a saved value is offered as
[entity:field_address:0:locality]. The last segment of such a token is the property name.
Quote tokens so that the YAML stays valid
Tokens are replaced per leaf value after the YAML structure has been
parsed, so every property can carry its own token. A token starts with [,
which YAML reads as the start of a list, so write title: "[node:title]"
rather than title: [node:title].
The compound fill runs in the form's submit phase
The three fill strategies for simple values write into the rendered form with JavaScript, while a compound value is set on the entity while the form is being processed. The model therefore does not run while the form carries unrelated validation errors, and the dialog shows those errors instead of a filled field. A widget that is cataloged as an editor, select or buttons widget also keeps its existing direct fill, even when it renders a compound field type.
Fields¶
Field widget value— config key:widget_value-
This field supports tokens.Type:
textarea· Required: no · Default: empty string Interpret above value as YAML format— config key:use_yaml-
Use this for compound fields, which need a value per field property instead of a single string. Provide a mapping of the field property names to their values, for example country_code: "DE" and locality: "Berlin" for an address field, or uri: "https://example.com" and title: "Example" for a link field. A list of such mappings fills a multi-value field. When using tokens and YAML altogether, make sure that tokens are wrapped as a string. Example: title: "[node:title]"
Type:
checkbox· Required: no · Default:falseOff by default, in which case Field widget value is returned as a plain string or as the token data that it holds.
Enable it for a compound field, where one item stores several properties. The
value is then parsed as YAML, and the result is a mapping of the field item's
property names, or a list of such mappings for a multi-value field. Tokens are
replaced per leaf value after parsing, so wrap each one in quotes:
title: "[node:title]".
Parsing is the whole effect of this checkbox. A value that does not parse is logged and the field stays unfilled, and a mapping carrying property names that the field type does not have is reported as an error message on the form. See Compound fields above for the workflow and for how to find the property names of a field.