Problem/Motivation

The component insert form cancel button is processed via ajax. Validation occurs before the ajax callback is executed, and any error messages that result will be displayed in the next modal opened.

Steps to reproduce

  1. Click a "+" add paragraph button in the builder.
  2. Choose a paragraph that has required fields.
  3. In the resulting paragraph edit modal form, immediately click "cancel" without adding anything.
  4. Click a "+" add paragraph button in the builder.
  5. The modal dialog displays an error message for the required field from the previous step.
  6. Become very confused.
Command icon 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

John Pitcairn created an issue. See original summary.

johnpitcairn’s picture

Title: Cancel button should not validate the form » Cancel button should not validate the form, errors appear on next modal opened
Status: Active » Needs review
StatusFileSize
new786 bytes

Patch unsets any form errors then returns early before behavior/paragraph validation if the triggering element was "cancel".

deepalij’s picture

Assigned: Unassigned » deepalij
johnpitcairn’s picture

@DeepaliJ: why is this assigned to you? It just needs review, right? Or are you doing more work on the patch?

johnpitcairn’s picture

Assigned: deepalij » Unassigned
johnpitcairn’s picture

Hmm, why does the cancel button need to perform a full ajax submit anyway? It could just close the modal, if we attach suitable js. But that could be a followup.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Patch works for me.

> Hmm, why does the cancel button need to perform a full ajax submit anyway

I don't know if the forms with without JS but there should be provision for that, so we need to handle it in the backend anyway.

justin2pin made their first commit to this issue’s fork.

justin2pin’s picture

Simplified to use the #limit_validation_errors option on the Cancel button.

  • justin2pin committed aeaf6f8d on 2.0.x
    Issue #3313147 by justin2pin, John Pitcairn, DeepaliJ, joachim: Cancel...
justin2pin’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.