You are here

function node_limit_limit_form in Node Limit 8

Same name and namespace in other branches
  1. 6 node_limit.module \node_limit_limit_form()
  2. 7 node_limit.module \node_limit_limit_form()

Implements hook_form().

The node_limit settings form.

1 string reference to 'node_limit_limit_form'
node_limit_menu in old/node_limit.module
Implements hook_menu().

File

old/node_limit.module, line 432

Code

function node_limit_limit_form($form, &$form_state, $limit = FALSE) {
  if (empty($limit)) {
    $limit = array(
      'lid' => 0,
      'title' => '',
      'weight' => 0,
      'nlimit' => NODE_LIMIT_NO_LIMIT,
    );
  }
  $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']['limit'] = 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' => check_plain($element['#title']),
      '#default_value' => isset($limit[$module]),
    );
    $element['#title'] = '';
    $form['node_limit_elements'][$module]['element'] = $element;
  }
  if (empty($form['node_limit_elements'])) {
    unset($form['node_limit_elements']);
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => $limit['lid'] > 0 ? t('Edit Node Limit') : t('Add Node Limit'),
  );
  return $form;
}