You are here

public function PaymentInformation::validatePaneForm in Commerce Core 8.2

Validates the pane form.

Parameters

array $pane_form: The pane form.

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

array $complete_form: The complete form structure.

Overrides CheckoutPaneBase::validatePaneForm

File

modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php, line 341

Class

PaymentInformation
Provides the payment information pane.

Namespace

Drupal\commerce_payment\Plugin\Commerce\CheckoutPane

Code

public function validatePaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) {
  if (!$this->order
    ->getTotalPrice() || $this->order
    ->isPaid() || $this->order
    ->getTotalPrice()
    ->isZero()) {
    return;
  }
  $values = $form_state
    ->getValue($pane_form['#parents']);
  if (!isset($values['payment_method'])) {
    $form_state
      ->setError($complete_form, $this
      ->noPaymentGatewayErrorMessage());
  }
}