public function OptionFormBase::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
- uc_attribute/
src/ Form/ OptionFormBase.php, line 88
Class
- OptionFormBase
- Defines the attribute option add/edit edit form.
Namespace
Drupal\uc_attribute\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$pattern = '/^-?\\d*(\\.\\d*)?$/';
if (!is_numeric($form_state
->getValue('weight')) && !preg_match($pattern, $form_state
->getValue('weight'))) {
$form_state
->setErrorByName('weight', $this
->t('This must be in a valid number format. No commas and only one decimal point.'));
}
}