You are here

function autoassignrole_page_form in Auto Assign Role 7.2

Same name and namespace in other branches
  1. 7 autoassignrole.admin.inc \autoassignrole_page_form()

Provides a FAPI form for adding and editing pages.

Parameters

array $form: The form API form array.

array $form_state: The form API form state array.

stdClass|null: The existing page object or NULL for a new page.

Return value

array A form API renderable array.

1 string reference to 'autoassignrole_page_form'
autoassignrole_menu in ./autoassignrole.module
Implements hook_menu().

File

./autoassignrole.admin.inc, line 224
Administrative functionality for auto assign role.

Code

function autoassignrole_page_form($form, &$form_state, stdClass $page = NULL) {
  $is_new = empty($page);
  if ($is_new) {
    $page = autoassignrole_page_create();
  }
  $form['is_new'] = array(
    '#type' => 'value',
    '#value' => $is_new,
  );
  $form['export_type'] = array(
    '#type' => 'value',
    '#value' => $page->export_type,
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Page Title'),
    '#description' => t('Enter the title of the page'),
    '#size' => 60,
    '#required' => TRUE,
    '#default_value' => $page->title,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#default_value' => $page->name,
    '#disabled' => !$is_new,
    '#machine_name' => array(
      'exists' => 'autoassignrole_page_load',
      'source' => array(
        'title',
      ),
    ),
    '#required' => TRUE,
  );
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Role'),
    '#description' => t('Select the roles this page will assign'),
    '#options' => autoassignrole_get_roles(),
    '#required' => TRUE,
    '#default_value' => $page->roles,
  );
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Page Path'),
    '#description' => t('Enter the Drupal path for the registration page for this role. This is a relative path based on your Drupal installation.'),
    '#size' => 60,
    '#required' => TRUE,
    '#default_value' => $page->path,
  );
  $form['menu'] = array(
    '#type' => 'select',
    '#title' => t('Menu'),
    '#description' => t('Which parent menu item should these pages appear under? This will only apply if you choose the "Standard" display option below.'),
    '#options' => menu_get_menus(),
    '#default_value' => $page->menu,
  );
  $form['display'] = array(
    '#type' => 'select',
    '#title' => t('Display type'),
    '#description' => t('Choose the way you would like these pages to be displayed.<br /><em>Standard</em> is equivalent to the core Drupal log in/ registration form, with tabs along the top.<br /><em>Individual</em> is a separate page without tabs.'),
    '#options' => array(
      AUTOASSIGNROLE_PAGE_DISPLAY_STANDARD => t('Standard'),
      AUTOASSIGNROLE_PAGE_DISPLAY_INDIVIDUAL => t('Individual'),
    ),
    '#default_value' => $page->display,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $is_new ? t('Add') : t('Save'),
  );
  return $form;
}