Problem/Motivation
The current handler runs the Monday relay in validateForm() when
block_submit_on_failure is enabled. Webform fires the full validate
cycle on every form-action click — the preview button, wizard next/previous buttons, and
the draft button — not just the final submit. The result is that a webform with a preview
step (preview: 1) or multiple wizard pages calls create_item
once per click, producing two or more duplicate Monday rows per submission.
Steps to reproduce
- Attach
monday_crm_integration_create_itemto a webform that has
preview: 1in settings (or has multiple wizard pages). - Leave
block_submit_on_failureat its defaulttrue. - Submit the form: click the preview button, then the final submit button on the
preview page. - Observe in Monday: two identical items created on the target board.
- Observe in watchdog (channel
monday_crm_integration): two log entries
per submission.
Proposed resolution
Refactor the handler to use the canonical Webform pattern. Concretely:
- Remove
validateForm()entirely. - Move the relay to
postSave(), gated on
$webform_submission->getState() === STATE_COMPLETED. Mirror the
results_disabledfallback thatEmailWebformHandler::postSave()
uses at line 884 so the relay still fires when the submission isn't persisted to the
DB. - Drop the
block_submit_on_failureconfiguration key. The submission
always saves; Monday delivery failures are surfaced to the submitter via
$this->messenger()->addError()using the existing
failure_error_messageconfig, and logged with full diagnostics in
relay()as before. - Update the field-help for
failure_error_messageto reflect its new role
(shown on failure regardless; leave empty to suppress).
This eliminates the duplicate-row bug by construction and aligns the handler with the
rest of the Webform ecosystem.
Remaining tasks
- Refactor
MondayCreateItemWebformHandler— drop
validateForm(), rewritepostSave(). - Update
defaultConfiguration(),buildConfigurationForm(),
submitConfigurationForm()to remove
block_submit_on_failure. - Add a kernel/functional test for the multi-step / preview-enabled case asserting
exactly one Monday call per submission. - Update
README.mdto document the new failure UX (submission always
saves;failure_error_messageshown to user, full diagnostics logged). - Add a release note flagging the breaking change for sites currently relying on
block_submit_on_failure: true
User interface changes
- The "Block the submission if Monday is unreachable" checkbox is removed from the
handler configuration form. - The "User-facing failure message" textarea remains, with updated help text
describing the new behavior.
API changes
- Breaking: the
block_submit_on_failurekey is removed
from the handler configuration. Existing webforms with this key set will need their config
updated (key removed). Drupal config-import will tolerate the extra key, but the value is
ignored. failure_error_messagebehavior changes: previously shown only when
block_submit_on_failure: trueand the relay failed during validation. Now
shown via the messenger whenever the relay fails, regardless of any other config.
Data model changes
None.
Release notes snippet
Refactored MondayCreateItemWebformHandler to the canonical Webform handler pattern: relay now runs in postSave() gated on STATE_COMPLETED, matching EmailWebformHandler and RemotePostWebformHandler. This fixes a duplicate-row bug where preview-enabled or multi-page wizard forms produced two Monday items per submission, because Webform fires validateForm on every wizard/preview/draft button click. BREAKING CHANGE: the `block_submit_on_failure` config key is removed. Submissions always proceed to save; Monday delivery failures are surfaced to the user via the messenger using the existing `failure_error_message` config, and logged with full diagnostics on the `monday_crm_integration` channel.
Issue fork monday_crm_integration-3606566
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
das.gautam commented