You are here

public function PaymentLineItemElement::submitForm in Payment 8.2

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormInterface::submitForm

File

modules/payment_test/src/PaymentLineItemElement.php, line 55

Class

PaymentLineItemElement

Namespace

Drupal\payment_test

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $line_items_data = [];

  /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface $line_item */
  foreach (PaymentLineItemsInput::getLineItems($form['container']['line_item'], $form_state) as $line_item) {
    $line_items_data[] = array(
      'plugin_id' => $line_item
        ->getPluginId(),
      'plugin_configuration' => $line_item
        ->getConfiguration(),
    );
  }
  \Drupal::state()
    ->set('payment_test_line_item_form_element', $line_items_data);
}