You are here

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

1 string reference to 'merci_cpm_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 71

Code

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

  // Populate the from with the selected profile.
  if (array_key_exists('autocomplete_profile_id', $form_state)) {
    $value[] = array(
      'profile_id' => $form_state['autocomplete_profile_id'],
    );

    // Set the profile_id form_state value and wipe out any entered addressfield data.
    form_set_value($element, $value, $form_state);
    unset($form_state['input'][$element['#field_name']]);
    unset($form_state['addressfield']);
    unset($form_state['autocomplete_profile_id']);
  }
  else {

    // Validate direct input.
    // But only if the profile type is enabled.
    unset($form_state['triggering_element']['#limit_validation_errors']);
    if (!empty($form_state['triggering_element']) && in_array('customer_profile_ui_checkboxes', $form_state['triggering_element']['#parents'], TRUE)) {
      form_set_value($element, array(), $form_state);
    }
    else {
      commerce_customer_profile_manager_validate($element, $form_state, $form);
    }

    //if (!empty($form_state['values']['customer_profile_ui_checkboxes'][$element['#field_name']])) {

    //  override_commerce_customer_profile_manager_validate($element, $form_state, $form);

    //}
  }
}