Same name in other branches
- 7.x-3.x quicktabs.admin.inc \quicktabs_form_validate()
Validation handler for quicktabs admin page.
Fichier
-
includes/
admin.inc, line 528
Code
function quicktabs_form_validate($form, &$form_state) {
if (empty($form_state['values']['machine_name'])) {
form_set_error('machine_name', t('The quicktabs ID is required.'));
}
else {
if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['machine_name'])) {
form_set_error('machine_name', t('The quicktabs machine name must contain only lowercase letters, numbers, and underscores.'));
}
}
if (empty($form_state['values']['title'])) {
form_set_error('title', t('Title is required for the quicktab block.'));
}
else {
if (!isset($form_state['values']['tabs'])) {
form_set_error('', t('At least one tab should be created.'));
}
foreach ($form_state['values']['tabs'] as $j => $tab) {
if (empty($tab['title'])) {
form_set_error('tabs][' . $j . '][title', t('Title is required for each tab.'));
}
elseif ($tab['type'] == 'qtabs' && $tab['qtabs']['machine_name'] == $form_state['values']['machine_name']) {
form_set_error('tabs][' . $j . '][qtabs][machine_name', t('You cannot put a quicktab inside itself.'));
}
elseif ($tab['type'] == 'view') {
// Remove spaces from view arguments.
$form_state['values']['tabs'][$j]['view']['args'] = str_replace(' ', '', $form_state['values']['tabs'][$j]['view']['args']);
}
}
}
}