Last active
August 24, 2022 04:46
-
-
Save gheydon/c630ff933301611c8dc339e2863343b8 to your computer and use it in GitHub Desktop.
When dealing with checkboxes, the #title that you use is sometimes not very good to be used with error messages. In this case you can add the '#element_title' to your element and it will replace the this title with so the original title can be used for the error messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_preprocess_HOOK(). | |
* | |
* HOOK: 'form_element' | |
*/ | |
function example_preprocess_form_element(&$variables) { | |
if (isset($variables['element']['#element_title'])) { | |
$variables['label']['#title'] = $variables['element']['#element_title']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment