You are here

public static function CustomerProfile::clearValues in Commerce Core 8.2

Clears form input when select_address is used.

File

modules/order/src/Plugin/Commerce/InlineForm/CustomerProfile.php, line 315

Class

CustomerProfile
Provides an inline form for managing a customer profile.

Namespace

Drupal\commerce_order\Plugin\Commerce\InlineForm

Code

public static function clearValues(array $element, FormStateInterface $form_state) {
  $triggering_element_name = static::getTriggeringElementName($element, $form_state);
  if ($triggering_element_name != 'select_address') {
    return $element;
  }
  $user_input =& $form_state
    ->getUserInput();
  $inline_form_input = NestedArray::getValue($user_input, $element['#parents']);
  $inline_form_input = array_intersect_assoc($inline_form_input, [
    'select_address' => $inline_form_input['select_address'],
  ]);
  NestedArray::setValue($user_input, $element['#parents'], $inline_form_input);
  return $element;
}