function auto_nodetitle_form_node_type_form_alter in Automatic Nodetitles 7
Same name and namespace in other branches
- 8 auto_nodetitle.module \auto_nodetitle_form_node_type_form_alter()
Implements hook_form_FORM_ID_alter() for the node type form.
File
- ./
auto_nodetitle.module, line 222 - Allows hiding of the node title field and automatic title creation.
Code
function auto_nodetitle_form_node_type_form_alter(&$form, &$form_state) {
$default_value = auto_nodetitle_get_setting($form['#node_type']->type);
$form['auto_nodetitle'] = array(
'#type' => 'fieldset',
'#title' => t('Automatic title generation'),
'#weight' => 0,
'#collapsible' => TRUE,
'#collapsed' => !$default_value,
'#group' => 'additional_settings',
'#attached' => array(
'js' => array(
'auto-nodetitle' => drupal_get_path('module', 'auto_nodetitle') . '/auto_nodetitle.js',
),
),
);
$form['auto_nodetitle']['ant'] = array(
'#type' => 'radios',
'#default_value' => $default_value,
'#options' => array(
t('Disabled'),
t('Automatically generate the title and hide the title field'),
t('Automatically generate the title if the title field is left empty'),
),
);
$form['auto_nodetitle']['ant_pattern'] = array(
'#type' => 'textarea',
'#title' => t('Pattern for the title'),
'#description' => t('Leave blank for using the per default generated title. Otherwise this string will be used as title. Use the syntax [token] if you want to insert a replacement pattern.'),
'#default_value' => variable_get('ant_pattern_' . $form['#node_type']->type, ''),
);
// Don't allow editing of the pattern if PHP is used, but the users lacks
// permission for PHP.
if (variable_get('ant_php_' . $form['#node_type']->type, '') && !user_access('use PHP for title patterns')) {
$form['auto_nodetitle']['ant_pattern']['#disabled'] = TRUE;
$form['auto_nodetitle']['ant_pattern']['#description'] = t('You are not allow the configure the pattern for the title, as you lack the %permission permission.', array(
'%permission' => t('Use PHP for title patterns'),
));
}
// Display the list of available placeholders if token module is installed.
if (module_exists('token')) {
$form['auto_nodetitle']['token_help'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
'node',
),
'#dialog' => TRUE,
);
}
$form['auto_nodetitle']['ant_php'] = array(
'#access' => user_access('use PHP for title patterns'),
'#type' => 'checkbox',
'#title' => t('Evaluate PHP in pattern.'),
'#description' => t('Put PHP code above that returns your string, but make sure you surround code in <?php and ?>. Note that $node is available and can be used by your code.'),
'#default_value' => variable_get('ant_php_' . $form['#node_type']->type, ''),
);
}