public function QuicklinkConfigForm::validateForm in Quicklink 2.0.x
Same name and namespace in other branches
- 8 src/Form/QuicklinkConfigForm.php \Drupal\quicklink\Form\QuicklinkConfigForm::validateForm()
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/ QuicklinkConfigForm.php, line 313
Class
- QuicklinkConfigForm
- Class QuicklinkConfig.
Namespace
Drupal\quicklink\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$parameterFieldsToValidate = array(
'total_request_limit',
'concurrency_throttle_limit',
'viewport_delay',
'idle_wait_timeout',
);
foreach ($parameterFieldsToValidate as $value) {
$formValue = $form_state
->getValues()[$value];
if ($formValue !== '' && (!is_numeric($formValue) || intval($formValue) != $formValue || $formValue < 0 || $formValue < '')) {
$form_state
->setErrorByName($value, t('%name must be a positive integer or zero.', array(
'%name' => $form['throttle_options'][$value]['#title'],
)));
}
}
parent::validateForm($form, $form_state);
}