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
Comment #2
jurgenhaasDon'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.
Comment #3
coaston commentedThank you, just a little hint is needed - should I start with "Build Form" or "After build form" when I need to achieve "cancel" button ?
Comment #4
jurgenhaasI usually go with the "Build form" event.
Comment #5
coaston commentedThank you. Will give a try.
Comment #6
coaston commentedIt works finally.
It seems i need to use additional event "form submit" and now "FORM:Compare Triggered Submission" works.