You are here

function merci_cpm_autocomplete_validate in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

1 string reference to 'merci_cpm_autocomplete_validate'
merci_cpm_field_widget_commerce_customer_profile_type_ui_manager_form_alter in merci_cpm/merci_cpm.module

File

merci_cpm/merci_cpm.module, line 98

Code

function merci_cpm_autocomplete_validate($element, &$form_state, $form) {

  // Look in banner first.  regexp looks for /\[(A[0-9]+)\]$/ which would also be caught by below.
  evergreen_erp_autocomplete_validate($element, $form_state, $form);

  // autocomplete_profile_id will not be set if this isn't banner autocomplete.
  if (!array_key_exists('autocomplete_profile_id', $form_state) or empty($form_state['autocomplete_profile_id'])) {
    $name = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
    $matches = array();

    // This preg_match() looks for the last pattern like [33334] and if found
    // extracts the numeric portion.
    $result = preg_match('/\\[([0-9]+)\\]$/', $name, $matches);
    if ($result > 0) {
      $form_state['autocomplete_profile_id'] = $matches[$result];
    }
  }
}