Implements hook_form_FORM_ID_alter() for taxonomy_term_form().
function path_form_taxonomy_term_form_alter(&$form, $form_state) {
// Make sure this does not show up on the delete confirmation form.
if (empty($form_state['confirm_delete'])) {
$term = $form_state['controller']
->getEntity($form_state);
$path = isset($term->tid) ? drupal_container()
->get('path.crud')
->load(array(
'source' => 'taxonomy/term/' . $term->tid,
)) : array();
if ($path === FALSE) {
$path = array();
}
$path += array(
'pid' => NULL,
'source' => isset($term->tid) ? 'taxonomy/term/' . $term->tid : NULL,
'alias' => '',
'langcode' => LANGUAGE_NOT_SPECIFIED,
);
$form['path'] = array(
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
'#tree' => TRUE,
'#element_validate' => array(
'path_form_element_validate',
),
);
$form['path']['alias'] = array(
'#type' => 'textfield',
'#title' => t('URL alias'),
'#default_value' => $path['alias'],
'#maxlength' => 255,
'#weight' => 0,
'#description' => t("Optionally specify an alternative URL by which this term can be accessed. Use a relative path and don't add a trailing slash or the URL alias won't work."),
);
$form['path']['pid'] = array(
'#type' => 'value',
'#value' => $path['pid'],
);
$form['path']['source'] = array(
'#type' => 'value',
'#value' => $path['source'],
);
$form['path']['langcode'] = array(
'#type' => 'value',
'#value' => $path['langcode'],
);
}
}