Same name and namespace in other branches
  1. 5.x modules/path/path.module \path_form_alter()
  2. 6.x modules/path/path.module \path_form_alter()

Implementation of hook_form_alter().

File

modules/path.module, line 251
Enables users to rename URLs.

Code

function path_form_alter($form_id, &$form) {
  if (user_access('create url aliases') && isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $path = $form['#node']->path;
    $form['path'] = array(
      '#type' => 'fieldset',
      '#title' => t('URL path settings'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($path),
      '#weight' => 30,
    );
    $form['path']['path'] = array(
      '#type' => 'textfield',
      '#default_value' => $path,
      '#maxlength' => 250,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Optionally specify an alternative URL by which this node 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.'),
    );
    if ($path) {
      $form['path']['pid'] = array(
        '#type' => 'value',
        '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path)),
      );
    }
  }
}