1 path.admin.inc | path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => LANGUAGE_NONE, 'pid' => NULL)) |
Form builder; Main URL alias pattern administration form.
Parameters
$path: An array containing the path ID, source, alias, and language code.
See also
path_admin_form_delete_submit()
Related topics
File
- core/
modules/ path/ path.admin.inc, line 125 - Admin page callbacks for the Path module.
Code
function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => LANGUAGE_NONE, 'pid' => NULL)) {
$field_prefix = url(NULL, array('absolute' => TRUE)) . (config_get('system.core', 'clean_url') ? '' : '?q=');
$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: <code>node/28</code> or <code>taxonomy/term/1</code>.'),
'#field_prefix' => $field_prefix,
'#required' => TRUE,
);
$form['alias'] = array(
'#type' => 'textfield',
'#title' => t('URL alias'),
'#default_value' => $path['alias'],
'#maxlength' => 255,
'#size' => 45,
'#description' => t('Specify an alternative path where this page will appear. Do not include a trailing slash.'),
'#field_prefix' => $field_prefix,
'#required' => TRUE,
);
// A hidden value unless language.module is enabled.
if (module_exists('language')) {
$language_options = language_list(TRUE, TRUE);
$form['langcode'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => $language_options,
'#empty_value' => LANGUAGE_NONE,
'#empty_option' => t('- None -'),
'#default_value' => $path['langcode'],
'#weight' => -10,
'#description' => t('A URL alias set for a specific language will always be used when displaying this page in that language, and takes precedence over URL 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 URL alias'),
);
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'),
'#limit_validation_errors' => array(array('actions'), array('pid')),
);
}
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => isset($_GET['destination']) ? $_GET['destination'] : 'admin/config/urls/path',
);
return $form;
}