function path_admin_form

Form constructor for the path administration form.

Parameters

$path: An array containing the path ID, source, alias, and language code.

See also

path_admin_form_validate()

path_admin_form_submit()

path_admin_form_delete_submit()

Related topics

1 string reference to 'path_admin_form'
path_admin_edit in drupal/core/modules/path/path.admin.inc
Page callback: Returns a form creating or editing a path alias.

File

drupal/core/modules/path/path.admin.inc, line 130
Administrative page callbacks for the path module.

Code

function path_admin_form($form, &$form_state, $path = array(
  'source' => '',
  'alias' => '',
  'langcode' => LANGUAGE_NOT_SPECIFIED,
  'pid' => NULL,
)) {
  $form['source'] = array(
    '#type' => 'textfield',
    '#title' => t('Existing system path'),
    '#default_value' => $path['source'],
    '#maxlength' => 255,
    '#size' => 45,
    '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'),
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )),
    '#required' => TRUE,
  );
  $form['alias'] = array(
    '#type' => 'textfield',
    '#title' => t('Path alias'),
    '#default_value' => $path['alias'],
    '#maxlength' => 255,
    '#size' => 45,
    '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )),
    '#required' => TRUE,
  );

  // A hidden value unless language.module is enabled.
  if (module_exists('language')) {
    $languages = language_list();
    foreach ($languages as $langcode => $language) {
      $language_options[$langcode] = $language->name;
    }
    $form['langcode'] = array(
      '#type' => 'select',
      '#title' => t('Language'),
      '#options' => $language_options,
      '#empty_value' => LANGUAGE_NOT_SPECIFIED,
      '#empty_option' => t('- None -'),
      '#default_value' => $path['langcode'],
      '#weight' => -10,
      '#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as <em>- None -</em>.'),
    );
  }
  else {
    $form['langcode'] = array(
      '#type' => 'value',
      '#value' => $path['langcode'],
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  if ($path['pid']) {
    $form['pid'] = array(
      '#type' => 'hidden',
      '#value' => $path['pid'],
    );
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#submit' => array(
        'path_admin_form_delete_submit',
      ),
    );
  }
  return $form;
}