You are here

public function CustomerProfile::submitInlineForm in Commerce Core 8.2

Submits the inline form.

Parameters

array $inline_form: The inline form, containing the following basic properties:

  • #parents: Identifies the location of the field values in $form_state.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the complete form.

Overrides InlineFormBase::submitInlineForm

File

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

Class

CustomerProfile
Provides an inline form for managing a customer profile.

Namespace

Drupal\commerce_order\Plugin\Commerce\InlineForm

Code

public function submitInlineForm(array &$inline_form, FormStateInterface $form_state) {
  parent::submitInlineForm($inline_form, $form_state);
  if (!isset($inline_form['rendered'])) {
    $form_display = $this
      ->loadFormDisplay();
    $form_display
      ->extractFormValues($this->entity, $inline_form, $form_state);
    $values = $form_state
      ->getValue($inline_form['#parents']);
    if (!empty($values['copy_to_address_book'])) {
      $this->entity
        ->setData('copy_to_address_book', TRUE);
    }
    else {
      $this->entity
        ->unsetData('copy_to_address_book');
    }
  }
  $this->entity
    ->save();
  if ($this->configuration['copy_on_save'] && $this->addressBook
    ->needsCopy($this->entity)) {
    $customer = $this
      ->loadUser($this->configuration['address_book_uid']);
    $this->addressBook
      ->copy($this->entity, $customer);
  }
}