Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After creating an element like this:
$form['tel'] = array(
'#type'=>'telfield',
'#title'=>'Votre numéro de téléphone',
'#title_display'=>'invisible',
'#placeholder' => 'Votre numéro de téléphone',
'#pattern'=>'\+?[0-9+*#,;]+',
'#attributes' => array(
'class'=>array('tooltip-me'),
)
);
I get the following error:
Fatal error: Call to undefined function form_validate_pattern() in /home/fullwebfactory/svn_trunk/drupal/includes/form.inc on line 1410
It appears to me that the following function from elements.module is calling a drupal 8 core function, "form_validate_pattern", that is not available in D7.
function elements_process_pattern($element) {
if (isset($element['#pattern']) && !isset($element['#attributes']['pattern'])) {
$element['#attributes']['pattern'] = $element['#pattern'];
$element['#element_validate'][] = 'form_validate_pattern';
}
return $element;
}
Comment | File | Size | Author |
---|---|---|---|
#5 | elements-pattern-validation-2029557-5.patch | 545 bytes | Lanny Heidbreder |
#2 | elements.module.process.pattern.patch | 501 bytes | RSTaylor |
Comments
Comment #1
RSTaylor CreditAttribution: RSTaylor commentedShould be 'elements_validate_pattern'
Comment #2
RSTaylor CreditAttribution: RSTaylor commentedComment #3
chasingmaxwell CreditAttribution: chasingmaxwell commentedLooks good to me. Thanks RSTaylor!
Comment #5
Lanny Heidbreder CreditAttribution: Lanny Heidbreder at Stone Ward commentedPatch rerolled
Comment #6
_Ben CreditAttribution: _Ben commentedI have the same problem. This patch work for me.
Comment #7
nod_Same here, patch fixed the issue.
Comment #9
Dave ReidCommitted #5 to 7.x-1.x. Sorry about this going unfixed for so long!