public function QuickTabsInstanceEditForm::validate in Quick Tabs 8.3
File
- src/
Form/ QuickTabsInstanceEditForm.php, line 263
Class
- QuickTabsInstanceEditForm
- Class QuickTabsInstanceEditForm.
Namespace
Drupal\quicktabs\FormCode
public function validate(array $form, FormStateInterface $form_state) {
$id = $form_state
->getValue('id');
if (empty($id)) {
$form_state
->setErrorByName('machine_name', $this
->t('The quicktabs machine name is required.'));
}
elseif (!preg_match('!^[a-z0-9_]+$!', $id)) {
$form_state
->setErrorByName('machine_name', $this
->t('The quicktabs machine name must contain only lowercase letters, numbers, and underscores.'));
}
$tabs = $form_state
->getValue('tabs');
if (!isset($tabs)) {
$form_state
->setErrorByName('', $this
->t('At least one tab should be created.'));
}
else {
foreach ($tabs as $j => $tab) {
if (empty($tab['title'])) {
$form_state
->setErrorByName('tabs][' . $j . '][title', $this
->t('Title is required for each tab.'));
}
}
}
}