You are here

public function USPSSettingsForm::validateForm in Ubercart 8.4

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

shipping/uc_usps/src/Form/USPSSettingsForm.php, line 234

Class

USPSSettingsForm
Configures USPS settings.

Namespace

Drupal\uc_usps\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!is_numeric($form_state
    ->getValue('rate_markup'))) {
    $form_state
      ->setErrorByName('rate_markup', $this
      ->t('Rate markup must be a numeric value.'));
  }
  if (!is_numeric($form_state
    ->getValue('weight_markup'))) {
    $form_state
      ->setErrorByName('weight_markup', $this
      ->t('Weight markup must be a numeric value.'));
  }
}