Skip to content

Workflow execution

This page describes what FlowDropWorkflowAction::executeWorkflow() does, so you can build workflows and nodes that fit it.

Request flow

  1. The action button posts the form over AJAX with #limit_validation_errors = [], so entity validation does not run.
  2. The callback checks use flowdrop field widget actions and loads the configured flowdrop_workflow entity.
  3. It clears the messenger, so only messages added by the workflow remain.
  4. It runs the workflow num_suggestions times (clamped to 3), stopping early on no_match.
  5. 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:

  1. Converts the result to an array (getOutput()->toArray() for result objects, the array itself otherwise).
  2. Returns the no_match marker if the output has a truthy no_match key.
  3. 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_PROPERTY is target_id, and getTargetElement() also finds Tagify's widget element and checkbox_tree elements.
  • In append mode, executeWorkflowWithFormState() loads the current references (one loadMultiple() call, view access 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 carry data-tag-id, data-tag-label and data-tag-entry, plus data-tree-widget="true" for tree widgets. The target selector reaches the JavaScript through drupalSettings.fwa_suggestion_target.