You are here

public function DonationForm::validateForm in Commerce Donate 8

Form validation 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 FormBase::validateForm

File

src/Form/DonationForm.php, line 212

Class

DonationForm
Provides the donation form.

Namespace

Drupal\commerce_donate\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $amount = $form_state
    ->getValue('amount_onetime')[0];
  if (!is_numeric($amount)) {
    $form_state
      ->setError($form['amount_onetime']['amount_onetime'], t('The amount must be a valid number.'));
  }
  $amount = $form_state
    ->getValue('amount_monthly')[0];
  if (!is_numeric($amount)) {
    $form_state
      ->setError($form['amount_monthly']['amount_monthly'], t('The amount must be a valid number.'));
  }
}