Form: ADD Submit Button - How to use it properly

Created on 5 August 2025, 20 days ago

Problem/Motivation

I want to add a "Cancel" button in Drupal forms using the ECA module, specifically by using the "ADD SUBMIT BUTTON (Danger)" task.

Problem:
I am unable to configure the button’s action to, for example, redirect the user to the previous page.

What I tried:

I used the [After BUILD Form] event and the [FORM:ADD SUBMIT BUTTON] action to add a button with:
Trigger name: "cancelled"
Label: "Cancel"

Then, I added a condition with [FORM:Compare Triggered Submission], comparing the triggered button to "cancelled". However, this did not work.

Troubleshooting:

By displaying the current triggered form button token ([current_form:triggered]), I found that the actual trigger name is "field_image_0_upload_button" instead of "cancelled".
When I change the condition to check for "field_image_0_upload_button", the flow works and I can redirect accordingly.

Additional attempts:
I switched the event to [BUILD form] instead of [After BUILD Form], but then the button and condition do not work at all.

Questions:
Is this behavior a bug or am I missing some configuration? Why is the trigger name different from the one I set?

The submit button requires all required fields (like Title) to be filled before submitting. Can this validation be bypassed when clicking the Cancel button so that I can redirect without filling the form?

πŸ’¬ Support request
Status

Active

Version

2.1

Component

Documentation

Created by

πŸ‡ΈπŸ‡°Slovakia coaston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @coaston
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Don't think there's a bug, we're using submit buttons ourselves as well and they work as expected. You may want to create a simple example to show what's going wrong, i.e. an ECA model without any dependencies other than ECA or Drupal core. Then we can have a look why it behaves unexpectedly.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    Thank you, just a little hint is needed - should I start with "Build Form" or "After build form" when I need to achieve "cancel" button ?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I usually go with the "Build form" event.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    I am lost :(...

    1. Build Form (article)
    2. Action FORM:ADD Submit button ie. Trigger name "abc" , label "ABC", type "Secondary"

    When I navigate to article node I can see button there, if I click on it it will redirect me to "/admin/content"

    How can I change that behavior so for example it will clone the current node, or display some message when I hit that button ? ...When I try to use additional action like "display message" or "Entity: Clone existing" it will clone the entity during the refresh the page no matter if I click on that submit button or not.

    so what should be step 3 actually ? I believe I need to use that trigger name anywhere, but not sure where..

  • πŸ‡ΈπŸ‡°Slovakia coaston

    It works finally.

    It seems i need to use additional event "form submit" and now "FORM:Compare Triggered Submission" works.

Production build 0.71.5 2024