You are here

function ife_match_form_id in Inline Form Errors 7.2

Same name and namespace in other branches
  1. 7 ife.module \ife_match_form_id()

Check if a form ID pattern matches a given form ID.

Parameters

string $form_id: The form ID to compare the pattern to.

string $form_id_pattern: A form ID pattern. Ex. webform_*.

Return value

bool TRUE if the pattern matches the form_id, FALSE otherwise.

1 call to ife_match_form_id()
ife_form_id_load in ./ife.module
Menu loader function to fetch a form id.

File

./ife.module, line 106
Drupal hooks.

Code

function ife_match_form_id($form_id, $form_id_pattern) {

  // Convert form_id_pattern to a regular expression: replace /* with asterisks.
  $to_replace = array(
    '/\\\\\\*/',
  );
  $replacements = array(
    '.*',
  );

  // Quote regular expression characters.
  $form_id_pattern_quoted = preg_quote($form_id_pattern, '/');

  // Create regular expression.
  $form_id_pattern_regex = '/^(' . preg_replace($to_replace, $replacements, $form_id_pattern_quoted) . ')$/';
  return (bool) preg_match($form_id_pattern_regex, $form_id);
}