You are here

public function PaymentMethodAddForm::submitForm in Commerce Core 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/src/Form/PaymentMethodAddForm.php, line 233

Class

PaymentMethodAddForm
Provides the payment method add form.

Namespace

Drupal\commerce_payment\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\commerce\Plugin\Commerce\InlineForm\EntityInlineFormInterface $inline_form */
  $inline_form = $form['add_payment_method']['#inline_form'];

  /** @var \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method */
  $payment_method = $inline_form
    ->getEntity();
  $this
    ->messenger()
    ->addMessage($this
    ->t('%label saved to your payment methods.', [
    '%label' => $payment_method
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.commerce_payment_method.collection', [
    'user' => $payment_method
      ->getOwnerId(),
  ]);
}