You are here

public function Donation::validatePaneForm in Commerce Donate 8

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

src/Plugin/Commerce/CheckoutPane/Donation.php, line 128

Class

Donation
Provides the donation pane.

Namespace

Drupal\commerce_donate\Plugin\Commerce\CheckoutPane

Code

public function validatePaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) {
  $values = $form_state
    ->getValue($pane_form['#parents']);
  $amount = $values['details']['amount'][0];
  if (!is_numeric($amount)) {
    $form_state
      ->setError($pane_form['details']['amount'], t('The amount must be a valid number.'));
  }
}