You are here

public function PayPalCheckout::validateConfigurationForm in Commerce PayPal 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides CheckoutFlowBase::validateConfigurationForm

File

src/Plugin/Commerce/CheckoutFlow/PayPalCheckout.php, line 57

Class

PayPalCheckout
Provides a custom checkout flow for use by PayPal Checkout.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\CheckoutFlow

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  $values = $form_state
    ->getValue($form['#parents']);
  $pane_values = $values['panes'];
  if (!isset($pane_values['paypal_checkout_payment_process']) || $pane_values['paypal_checkout_payment_process']['step_id'] !== 'payment') {
    $pane = $this
      ->getPane('paypal_checkout_payment_process');
    $form_state
      ->setError($form['panes'], $this
      ->t('The %title pane must be configured in the payment region.', [
      '%title' => $pane
        ->getLabel(),
    ]));
  }
}