Form constructor for the path administration form.
$path: An array containing the path ID, source, alias, and language code.
path_admin_form_delete_submit()
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;
}