Problem / Motivation:

With ife making it to core, it is important to match the markup used in Core (both with and without IFE) to ensure errors don't pile up for the same field when a clientside validation shown for a field having an error from server side (after submitting the form)

Proposed solution:

Match the markup for the error label/div to match the one in core by default and allow it to be overridden the way it is allowed in core. This way code to remove existing errors before showing the new one will remove the ones provided by IFE / Core after form submit before showing the new error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nikunjkotecha created an issue. See original summary.

Jelle_S’s picture

We did this for Drupal 7 and ended up with a ton of submodules and hard to maintain code. We decided for D8 to leverage the plugin system for custom validation requirements, which means it's up to the contrib modules to decide whether or not they want to support Clientside Validation. Unless @attiks disagrees with me of course

nikunjkotecha’s picture

I'm working on custom patch right now for this and wanted to detail out in description later tonight.

Currently the only issue that I face and I feel should be fixed is to ensure two messages are not displayed. We need to allow hooking into the JS options in a way that other modules can modify the error message markup and also to take some action if required.

For instance, in this current case - I get div.form-item--error-message from inline_form_errors and then clientside_validation module adds label.error and to end user both are displayed.

Hope this makes sense, for sure we can change the ticket to allow hooking into clientside_validation module to make it more relevant.

nikunjkotecha’s picture

FileSize
2.1 KB

Adding basic patch to fix UI bug mentioned above.

nikunjkotecha’s picture

Title: Support inline_form_errors module » Update error markup to match the one provided by core
Issue summary: View changes
nikunjkotecha’s picture

Issue summary: View changes
nikunjkotecha’s picture

Status: Active » Needs review
FileSize
2.68 KB

Did two things in this patch:

  • Triggered new custom event to allow overriding of options passed to validate().
  • Updated error markup to show the same way as inline_form_errors core module.

@Jelle_S: Possible to review this one?

  • nikunjkotecha committed abd86e8 on 8.x-1.x
    Issue #2906132 by nikunjkotecha: Update error markup to match the one...
nikunjkotecha’s picture

Status: Needs review » Fixed

Updated the code, moved ife related stuff to separate js file and in the main file added only the event trigger to allow any module to update options. This is more extensible now and supports ife like ckeditor.

Status: Fixed » Closed (fixed)

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