Format Validation of Controls in a Widget #33866
JohnnyHerms
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the Problem
We're creating an elementor addon which includes a custom widget. Our widget uses Elementor TEXT controls for a phone number, fax number, email address. We also use an Elementor URL control for a website url. I would like to do format validation on these controls and show a warning to the user if it doesn't match the format. For example, the phone number should only allow digits, spaces, hyphens, parentheses and x/X for extension. I can't find any elementor documentation of how to do this. There's only documentation of how to do this for form fields but that doesn't apply to controls
Propose a Solution
Implement function(s) within Base_Control class (and/or other control classes)of Elementor Core that allows controls to define explicit patterns (regex patterns) of what is an acceptable format.
any widget that extends from Widget_Base can then validate its controls against the expected pattern to see if there's a valid format. If there's not a format, there should be an option to show a warning or an error somewhere in the editor preview. A warning would still allow you to publish the page, whereas an error would not allow you to publish the page until the error is fixed.
Ideally this warning/error message would appear in the editor panel underneath/beside the control that has the validation error.
Additional Context
I know that elementor developer docs support validation of form fields, however there is no validation available for Editor Controls.
Agreement
Beta Was this translation helpful? Give feedback.
All reactions