You are here

function flag_add_form in Flag 6

Same name and namespace in other branches
  1. 5 includes/flag.admin.inc \flag_add_form()
  2. 6.2 includes/flag.admin.inc \flag_add_form()
  3. 7.3 includes/flag.admin.inc \flag_add_form()
  4. 7.2 includes/flag.admin.inc \flag_add_form()

Present a form for creating a new flag, setting the type of flag.

1 string reference to 'flag_add_form'
flag_add_page in includes/flag.admin.inc
Menu callback for adding a new flag.

File

includes/flag.admin.inc, line 119
Contains administrative pages for creating, editing, and deleting flags.

Code

function flag_add_form(&$form_state) {
  $form = array();
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Flag name'),
    '#description' => t('The machine-name for this flag. It may be up to 32 characters long and my only contain lowercase letters, underscores, and numbers. It will be used in URLs and in all API calls.'),
    '#maxlength' => 32,
    '#required' => TRUE,
  );
  $types = array();
  foreach (flag_fetch_definition() as $type => $info) {
    $types[$type] = $info['title'] . '<div class="description">' . $info['description'] . '</div>';
  }
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => t('Flag type'),
    '#default_value' => 'node',
    '#description' => t('The type of content this flag will affect. An individual flag can only affect one type of content. This cannot be changed once the flag is created.'),
    '#required' => TRUE,
    '#options' => $types,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}