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;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RSTaylor’s picture

Issue summary: View changes

Should be 'elements_validate_pattern'

RSTaylor’s picture

chasingmaxwell’s picture

Status: Active » Reviewed & tested by the community

Looks good to me. Thanks RSTaylor!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: elements.module.process.pattern.patch, failed testing.

Lanny Heidbreder’s picture

Status: Needs work » Needs review
FileSize
545 bytes

Patch rerolled

_Ben’s picture

Status: Needs review » Reviewed & tested by the community

I have the same problem. This patch work for me.

nod_’s picture

Same here, patch fixed the issue.

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed #5 to 7.x-1.x. Sorry about this going unfixed for so long!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.