You are here

function flag_add_form in Flag 5

Same name and namespace in other branches
  1. 6.2 includes/flag.admin.inc \flag_add_form()
  2. 6 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 113
Contains administrative pages for creating, editing, and deleting flags.

Code

function flag_add_form() {
  $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['drupal-5-warning'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Important note concerning the limitation of Views 1.x'),
    '#description' => t('<p>You\'re using Drupal 5.</p><p>This module utilizes <a href="http://drupal.org/project/views">Views</a> to produce lists of flagged content. Since you\'re using Drupal 5, you will be using Views 1.x.</p><p>Since Views 1.x can only produce lists of <em>nodes</em>, you won\'t be able to produce lists of flagged <em>users</em> (or of flagged <em>comments</em>) with it. Therefore, while this module lets you flag users and comments, you may not find this feature useful. We have <a href="http://drupal.org/node/303589">a handbook page explaining the limitations of the Drupal 5 version of this module</a>.</p><p><strong>Note, however, that you can still flag and list users; but indirectly:</strong></p><p>Many Drupal 5 websites use modules such as <a href="http://drupal.org/project/bio">Bio</a> or <a href="http://drupal.org/project/nodeprofile">Node Profile</a>, that create corresponding nodes for users. So, instead of flagging users directly, you can flag <strong>these</strong> nodes. Views can easily produce a list of them.</p><p>In other words, if you\'re using Bio or Node Profile, and you want to flag users, make your flag of type "Nodes".</p>'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}