function _entity_legal_document_form_add_path_settings in Entity Legal 7
Same name and namespace in other branches
- 7.2 entity_legal.admin.inc \_entity_legal_document_form_add_path_settings()
Add path and pathauto settings to an existing legal document form.
1 call to _entity_legal_document_form_add_path_settings()
- entity_legal_document_form in ./
entity_legal.admin.inc - Generates the profile type editing form.
File
- ./
entity_legal.admin.inc, line 170 - Administration hooks and helpers for entity_legal module.
Code
function _entity_legal_document_form_add_path_settings(&$form, &$form_state, EntityLegalDocument $entity, $op) {
if (!module_exists('path')) {
return;
}
$path = array();
if (!in_array($op, array(
'add',
'clone',
))) {
$default_uri = $entity
->uri();
$conditions = array(
'source' => $default_uri['path'],
);
$path = path_load($conditions);
if ($path === FALSE) {
$path = array();
}
}
$form['path'] = array(
'#type' => 'fieldset',
'#title' => t('URL path settings'),
'#collapsible' => TRUE,
'#collapsed' => empty($path['alias']),
'#group' => 'settings',
'#attributes' => array(
'class' => array(
'path-form',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'path') . '/path.js',
),
),
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
'#weight' => 5,
'#tree' => TRUE,
'#element_validate' => array(
'path_form_element_validate',
),
);
$form['path']['alias'] = array(
'#type' => 'textfield',
'#title' => t('URL alias'),
'#default_value' => !empty($path['alias']) ? $path['alias'] : '',
'#maxlength' => 255,
'#description' => t('Optionally specify an alternative URL by which this content 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.'),
);
$form['path']['language'] = array(
'#type' => 'value',
'#value' => LANGUAGE_NONE,
);
$form['path']['pid'] = array(
'#type' => 'value',
'#value' => !empty($path['pid']) ? $path['pid'] : '',
);
$form['path']['source'] = array(
'#type' => 'value',
'#value' => !empty($path['source']) ? $path['source'] : '',
);
}