Workflow execution¶
This page describes what FlowDropWorkflowAction::executeWorkflow() does, so
you can build workflows and nodes that fit it.
Request flow¶
- The action button posts the form over AJAX with
#limit_validation_errors = [], so entity validation does not run. - The callback checks
use flowdrop field widget actionsand loads the configuredflowdrop_workflowentity. - It clears the messenger, so only messages added by the workflow remain.
- It runs the workflow
num_suggestionstimes (clamped to 3), stopping early onno_match. - It collects and clears messenger messages, then returns suggestions or an inline message.
Each run builds an OrchestrationRequest and passes it to
flowdrop_runtime.synchronous_pipeline_orchestrator. The pipeline ID is
field_widget_<workflow id>_<uuid>, so each run is tracked as its own
pipeline.
Initial context¶
The action only gives initial data to nodes whose node type is
flowdrop_field_widget_actions_field_content_processor. Each such node gets:
| Key | Value |
|---|---|
entity_type |
Entity type ID of the form entity, for example node. |
bundle |
Bundle of the form entity. |
entity_id |
Entity ID, or NULL for a new entity. |
target_field |
Machine name of the field the button belongs to. |
entity_values |
$form_state->getValues(), minus Form API keys. |
These keys are removed from entity_values before the run: form_build_id,
form_token, form_id, op, submit, preview, delete, actions,
advanced, revision_information, revision, changed.
Values are raw form state values, not field item lists. A text field looks
like [0 => ['value' => '...', 'format' => 'basic_html']]; a managed file
widget like [0 => ['fids' => [58], ...]].
Reading the result¶
The orchestrator returns results keyed by node ID. For each node, in order, the action:
- Converts the result to an array (
getOutput()->toArray()for result objects, the array itself otherwise). - Returns the
no_matchmarker if the output has a truthyno_matchkey. - Returns
(string) $output[$outputKey]if the key is set.
If no node has the key, a warning is logged with the node IDs and the run counts as empty. Empty strings are not added as suggestions.
flowchart TD
R[Node results in order] --> N{no_match truthy?}
N -- yes --> NM[Stop all runs, show no-match message]
N -- no --> K{output key set?}
K -- yes --> S[Use as suggestion]
K -- no --> Next[Next node]
Next --> N
Next -->|no nodes left| E[Empty run, warning logged]
Responses¶
| Situation | Response |
|---|---|
| No permission, no workflow configured, or workflow not loadable | Error MessageCommand. |
no_match |
Inline warning next to the field. |
| No suggestions | Inline message: first workflow messenger message by severity (error, warning, status), or a generic warning. |
| Suggestions (text action) | returnSuggestions() from Field Widget Actions. |
| Suggestions (entity reference action) | Modal dialog with chips; see below. |
| Exception | Error logged to flowdrop_field_widget_actions, generic error message. |
Entity reference specifics¶
EntityReferenceWorkflowAction changes three things:
FORM_ELEMENT_PROPERTYistarget_id, andgetTargetElement()also finds Tagify'swidgetelement andcheckbox_treeelements.- In append mode,
executeWorkflowWithFormState()loads the current references (oneloadMultiple()call,viewaccess checked) and merges them with the workflow result by ID. returnSuggestions()parses every suggestion with the(ID)pattern, de-duplicates by ID across all runs, and opens a dialog of chips. Chips carrydata-tag-id,data-tag-labelanddata-tag-entry, plusdata-tree-widget="true"for tree widgets. The target selector reaches the JavaScript throughdrupalSettings.fwa_suggestion_target.