Closed (fixed)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 Apr 2017 at 13:05 UTC
Updated:
23 Apr 2017 at 15:10 UTC
Jump to comment: Most recent
Comments
Comment #2
jrockowitz commentedI recommend using
hook_webform_element_alter()orhook_webform_element_ELEMENT_TYPE_alter()and adding a #element_validate callback.@see http://cgit.drupalcode.org/webform/tree/webform.api.php
Once you figure this out, could please post a recipe about "How to add custom validation to a webform element?"
Comment #3
matzab commentedHi jrockowitz,
I'll look at it tomorrow and will definitely post a recipe ;)
Comment #4
matzab commentedRecipe can be found here: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-ad...
Comment #5
jrockowitz commentedThe recipe is great. I actually never thought to use a static class for custom validation callback. I was still using procedural functions.
Comment #6
matzab commentedI wanted to separate the validation callback from the module file to keep the code clean. That was the best way to do it ;)
Thanks for convincing me to write the recipe. I'm quite new to the "Drupal world" and looking forward to contribute more and more.