You are here

public function SimpleCheckoutForm::validateForm in Stripe 2.x

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

modules/stripe_examples/src/Form/SimpleCheckoutForm.php, line 75

Class

SimpleCheckoutForm
Class SimpleCheckout.

Namespace

Drupal\stripe_examples\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('first') != 'John') {
    $form_state
      ->setError($form['first'], $this
      ->t('"John" is the only valid first name on this example.'));
  }
}