You are here

function simple_access_group_form in Simple Access 7.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_group_form()
  2. 5 simple_access.module \simple_access_group_form()
  3. 6.2 simple_access.admin.inc \simple_access_group_form()

Simple Access group form.

1 string reference to 'simple_access_group_form'
simple_access_menu in ./simple_access.module
Implements hook_menu().

File

./simple_access.admin.inc, line 70
House all the admin functions in inc to make the foot print a lot smaller.

Code

function simple_access_group_form($form, &$form_state, $group = array()) {
  if (!empty($group)) {
    drupal_set_title(t('Edit Access Group'));
    $form['gid'] = array(
      '#type' => 'value',
      '#value' => $group['gid'],
    );
  }
  else {
    drupal_set_title(t('Create Access Group'));
  }
  $group += array(
    'name' => '',
    'roles' => array(),
    'weight' => 0,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $group['name'],
    '#size' => 40,
    '#maxlength' => 80,
    '#description' => t('The name for the access group as it will appear on the content editing form.'),
    '#required' => TRUE,
  );
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => $group['roles'],
    '#options' => user_roles(),
    '#description' => t('Roles that can view'),
  );
  $form['weight'] = array(
    '#type' => 'weight',
    '#title' => 'Weight',
    '#default_value' => $group['weight'],
    '#delta' => 10,
    '#description' => t('When setting permissions, heavier names will sink and lighter names will be positioned nearer the top.'),
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}