public function MiniDonationForm::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/ MiniDonationForm.php, line 119
Class
- MiniDonationForm
- Provides the donation form.
Namespace
Drupal\commerce_donate\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$amount = $form_state
->getValue('amount')[0];
if (!is_numeric($amount)) {
$form_state
->setError($form['amount'], t('The amount must be a valid number.'));
}
}