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
- Install commerce and email_validator
- Create a new checkout flow
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | email_validator-add-support-for-nested-elements-3272431-4.patch | 697 bytes | zevior |
| #2 | email_validator-add-support-for-nested-elements-3272431-1.patch | 315 bytes | zevior |
Comments
Comment #2
zevior commentedAdds 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.Comment #3
zevior commentedComment #4
zevior commentedNew patch fixes setting the form error by the correct name
Comment #6
saidatom