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?

Comments

coaston created an issue. See original summary.

jurgenhaas’s picture

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.

coaston’s picture

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 ?

jurgenhaas’s picture

I usually go with the "Build form" event.

coaston’s picture

Thank you. Will give a try.

coaston’s picture

Status: Active » Closed (works as designed)

It works finally.

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