function flatcomments_existing_form_validate in Flatcomments 6
Same name and namespace in other branches
- 6.2 flatcomments_existing/flatcomments_existing.admin.inc \flatcomments_existing_form_validate()
Form validation; checks that node type(s) are selected, and all valid. The checks are executed on both passes of the form.
File
- flatcomments_existing/
flatcomments_existing.admin.inc, line 50 - Administrative callbacks to provide the functionality of flattening previously existing comments.
Code
function flatcomments_existing_form_validate($form, &$form_state) {
$content_types = node_get_types('names');
$is_selected = FALSE;
$is_valid = TRUE;
foreach ($form_state['values']['types'] as $type => $value) {
if (!empty($value)) {
$is_selected = TRUE;
if (!isset($content_types[$type])) {
$is_valid = FALSE;
}
}
}
if (!$is_selected || !$is_valid) {
form_set_error('types', t('You must choose at least one valid content type.'));
}
}