function node_limit_limit_form in Node Limit 6
Same name and namespace in other branches
- 8 old/node_limit.module \node_limit_limit_form()
- 7 node_limit.module \node_limit_limit_form()
The node_limit settings form.
1 string reference to 'node_limit_limit_form'
- node_limit_menu in ./
node_limit.module - Implementation of hook_menu().
File
- ./
node_limit.module, line 317 - Module to restrict the number of nodes a user or role may create.
Code
function node_limit_limit_form(&$form_state, $limit) {
if ($limit == FALSE) {
$limit = array();
}
$form = array();
$form['#tree'] = TRUE;
if ($limit['lid'] > 0) {
$form['lid'] = array(
'#type' => 'hidden',
'#value' => $limit['lid'],
);
}
$form['info']['title'] = array(
'#title' => t('Description'),
'#type' => 'textfield',
'#default_value' => $limit['title'],
'#required' => TRUE,
'#description' => t('The description for this Node Limit'),
);
$form['info']['nlimit'] = array(
'#title' => t('Limit'),
'#type' => 'textfield',
'#default_value' => isset($limit['nlimit']) ? $limit['nlimit'] : NODE_LIMIT_NO_LIMIT,
'#size' => 10,
'#required' => TRUE,
'#description' => t('The number of nodes for this limit. Must be an integer greater than 0 or %nolimit for no limit', array(
'%nolimit' => NODE_LIMIT_NO_LIMIT,
)),
);
$form['info']['weight'] = array(
'#type' => 'hidden',
'#value' => $limit['weight'],
);
$elements = module_invoke_all('node_limit_element', $limit['lid']);
$form['node_limit_elements'] = array();
foreach ($elements as $module => $element) {
$form['node_limit_elements'][$module]['applies'] = array(
'#type' => 'checkbox',
'#title' => $element['#title'],
'#default_value' => isset($limit[$module]),
);
$element['#title'] = '';
$form['node_limit_elements'][$module]['element'] = $element;
}
$form['save'] = array(
'#type' => 'submit',
'#value' => $limit['lid'] > 0 ? t('Edit Node Limit') : t('Add Node Limit'),
);
return $form;
}