public function UPSSettingsForm::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_ups/ src/ Form/ UPSSettingsForm.php, line 323
Class
- UPSSettingsForm
- Configures UPS settings.
Namespace
Drupal\uc_ups\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$old_password = $this
->config('uc_ups.settings')
->get('password');
if (!$form_state
->getValue('uc_ups_password')) {
if ($old_password) {
$form_state
->setValueForElement($form['credentials']['password'], $old_password);
}
else {
$form_state
->setErrorByName('password', $this
->t('Password field is required.'));
}
}
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.'));
}
}