I want to overwrite the maximum charcater limit to 320. It is defined in /core/lib/Drupal/Core/Render/Element/Email.php
Can anybody tell me how to overwrite it?
I want to overwrite the maximum charcater limit to 320. It is defined in /core/lib/Drupal/Core/Render/Element/Email.php
Can anybody tell me how to overwrite it?
You can using hook_element_info_alter.
mymodule.module
/*
* Implements hook_element_info_alter().
*/
function mymodule_element_info_alter(array &$info) {
if (!empty($info['email'])) {
$info['email']['#maxlength'] = 320;
}
}
Flush all caches so hook gets pickedup.
As Neograph734 pointed out, the mail column's VARCHAR length will also have to be increased in the DB. See Resizing Fields in Drupal 8 Without Losing Data to learn how you can accomplish that.
varchar(254)
. So you will not be able to store the longer value.
Commented
Oct 12, 2020 at 12:06
<
and >
)
This can be only changed in patching core , there is a patch contributed here https://www.drupal.org/project/drupal/issues/3177834