Problem/Motivation

While implementing this module in a commerce project to validate the email field inside a pane i noticed that the field part of the configuration only supports fields that are not nested inside form elements. I found some code in validateCustomForm that fixes the problem for form id commerce_checkout_flow_multistep_default for the pane contact_information, but my project has a custom checkout flow and a custom contact information pane, so this fix didn't work.

Steps to reproduce

  1. Install commerce and email_validator
  2. Create a new checkout flow
  3. Attempt to implement email validation on the checkout flow

Proposed resolution

Add generic support for nested fields, where the config line can chain multiple keys together with a new separator.

Remaining tasks

  • Implement changes (simple patch incoming)
  • Add documentation

User interface changes

Documentation needed

API changes

-

Data model changes

Config now supports chaining keys, fully backwards compatible.

Comments

Zevior created an issue. See original summary.

zevior’s picture

Status: Active » Needs review
StatusFileSize
new315 bytes

Adds a simple explode on . characters (meaning my config can look something like commerce_checkout_flow_projectname_multistep:projectname_contact_information.email.
$form_state->getValue() supports an array as parameter and will get the nested value. Could not find any other code in the module that would break if the key becomes an array.

zevior’s picture

Issue summary: View changes
zevior’s picture

New patch fixes setting the form error by the correct name

  • saidatom committed e0a44950 on 8.x.2.x
    Issue #3272431 by Zevior: Add support for validating nested elements.
    
saidatom’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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