function node_limit_limit_form_validate in Node Limit 8
Same name and namespace in other branches
- 6 node_limit.module \node_limit_limit_form_validate()
- 7 node_limit.module \node_limit_limit_form_validate()
Validation hook for node_limit_limit_form.
Allows submodules that are applied to validate their own input.
File
- old/
node_limit.module, line 498
Code
function node_limit_limit_form_validate($form_id, &$form_state) {
if (!is_numeric($form_state['values']['info']['limit'])) {
form_set_error('info][limit', t('Node limits must be an integer'));
}
elseif (intval($form_state['values']['info']['limit']) != floatval($form_state['values']['info']['limit'])) {
// Can't use is_int because is_int("2") == FALSE.
form_set_error('info][limit', t('Node limits must be an integer'));
}
elseif (intval($form_state['values']['info']['limit']) < NODE_LIMIT_NO_LIMIT) {
form_set_error('info][limit', t('Node limits cannot be less that %nolimit', array(
'%nolimit' => NODE_LIMIT_NO_LIMIT,
)));
}
if (trim($form_state['values']['info']['title']) == '') {
form_set_error('info][title', t('Invalid Node Limit title'));
}
if (!empty($form_state['values']['node_limit_elements'])) {
foreach ($form_state['values']['node_limit_elements'] as $module => $element) {
if ($element['applies'] === 1) {
// They checked the box!
$result = module_invoke($module, 'node_limit_element_validate', $element['element']);
if (is_array($result) && isset($result['error'])) {
$path = $module . '][element';
if (isset($result['element'])) {
$path .= '][' . $result['element'];
}
form_set_error('node_limit_elements][' . $path, $result['error']);
}
}
}
}
}