You are here

public function PaymentFormConfigurationForm::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 ConfigFormBase::submitForm

File

modules/payment_form/src/Plugin/Payment/Type/PaymentFormConfigurationForm.php, line 127

Class

PaymentFormConfigurationForm
Provides the configuration form for the payment_form payment type plugin.

Namespace

Drupal\payment_form\Plugin\Payment\Type

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $plugin_selector = $this
    ->getPluginSelector($form_state);
  $plugin_selector
    ->submitSelectorForm($form['plugin_selector'], $form_state);
  $selected_plugin = $plugin_selector
    ->getSelectedPlugin();
  $config = $this
    ->config('payment_form.payment_type');
  $values = $form_state
    ->getValues();
  $config
    ->set('plugin_selector_id', $selected_plugin
    ->getPluginId());
  if (PluginHelper::isConfigurable($selected_plugin)) {
    $selected_plugin_configuration = $selected_plugin
      ->getConfiguration();
  }
  else {
    $selected_plugin_configuration = [];
  }
  $config
    ->set('plugin_selector_configuration', $selected_plugin_configuration);
  $config
    ->set('limit_allowed_plugins', $values['limit_allowed_plugins']);
  $config
    ->set('allowed_plugin_ids', $values['allowed_plugin_ids']);
  $config
    ->save();
  parent::submitForm($form, $form_state);
}