public function SettingsForm::validateForm in BigBlueButton 8
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/ SettingsForm.php, line 111
Class
- SettingsForm
- Provides an administration settings form.
Namespace
Drupal\bbb\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$url_key = [
'bbb_server',
'base_url',
];
$url = $form_state
->getValue($url_key);
if (empty($url)) {
$form_state
->setErrorByName(implode('][', $url_key), $this
->t('Base url should not be empty.'));
}
else {
if (strpos($url, 'http') !== 0) {
$form_state
->setErrorByName(implode('][', $url_key), $this
->t('Base url protocol is not defined. Use one of <em>http://</em> or <em>https://</em>.'));
}
if (substr($url, -1) !== '/') {
$form_state
->setErrorByName(implode('][', $url_key), $this
->t('Base url should end with <em>/</em> <em>(the slash symbol)</em>.'));
}
if (substr($url, -5) === '/api/') {
$form_state
->setErrorByName(implode('][', $url_key), $this
->t('Do not set <em>api/</em> suffix.'));
}
}
parent::validateForm($form, $form_state);
}