You are here

function commerce_customer_add_profile_callback in Commerce Core 7

Ajax callback to select and return only the form elements that will replace the add profile button.

1 string reference to 'commerce_customer_add_profile_callback'
commerce_customer_field_widget_form in modules/customer/commerce_customer.module
Implements hook_field_widget_form().

File

modules/customer/commerce_customer.module, line 1159
Defines the customer profile entity and API functions to manage customers and interact with them.

Code

function commerce_customer_add_profile_callback($form, &$form_state) {

  // Reverse the array parents of the triggering element, because we know the
  // field name is 5 elements up from the triggering element.
  $parents = array_reverse($form_state['triggering_element']['#array_parents']);
  $field_name = $parents[5];
  $langcode = $form[$field_name]['#language'];
  return $form[$field_name][$langcode];
}