function auto_entitylabel_settings_form in Automatic Entity Label 7
Administration form for each bundle.
1 string reference to 'auto_entitylabel_settings_form'
- auto_entitylabel_menu in ./
auto_entitylabel.module - Implements hook_menu().
File
- ./
auto_entitylabel.admin.inc, line 73 - Contains administration forms.
Code
function auto_entitylabel_settings_form($form, $form_state, $entity_type, $bundle_arg) {
$info = entity_get_info($entity_type);
$bundle_name = is_object($bundle_arg) ? $bundle_arg->{$info['bundle keys']['bundle']} : $bundle_arg;
$bundle_label = $info['bundles'][$bundle_name]['label'];
$key = $entity_type . '_' . $bundle_name;
$default_value = auto_entitylabel_get_setting($key);
$form['auto_entitylabel'] = array(
'#type' => 'fieldset',
'#title' => t('Automatic label generation for @type', array(
'@type' => $bundle_label,
)),
'#weight' => 0,
'#attached' => array(
'js' => array(
'auto-entitylabel' => drupal_get_path('module', 'auto_entitylabel') . '/js/auto_entitylabel.admin.js',
),
),
);
$form['auto_entitylabel']['auto_entitylabel_' . $key] = array(
'#type' => 'radios',
'#default_value' => $default_value,
'#options' => _auto_entitylabel_options($entity_type, $bundle_name),
);
$form['auto_entitylabel']['auto_entitylabel_pattern_' . $key] = 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('auto_entitylabel_pattern_' . $key, ''),
'#attributes' => array(
'class' => array(
'pattern-label',
),
),
);
// Don't allow editing of the pattern if PHP is used, but the users lacks
// permission for PHP.
if (variable_get('auto_entitylabel_php_' . $key, '') && !user_access('use PHP for label patterns')) {
$form['auto_entitylabel']['auto_entitylabel_pattern_' . $key]['#disabled'] = TRUE;
$form['auto_entitylabel']['auto_entitylabel_pattern_' . $key]['#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_entitylabel']['token_help'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
$info['token type'],
),
'#dialog' => TRUE,
);
}
else {
$form['auto_entitylabel']['auto_entitylabel_pattern_' . $key]['#description'] .= ' ' . t('To get a list of available tokens install <a href="@url-token" target="blank">Token</a> module.', array(
'@url-token' => 'https://www.drupal.org/project/token',
));
}
$form['auto_entitylabel']['auto_entitylabel_php_' . $key] = array(
'#access' => user_access('use PHP for label 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 <code><?php</code> and <code>?></code>. Note that <code>$entity</code> and <code>$language</code> are available and can be used by your code.'),
'#default_value' => variable_get('auto_entitylabel_php_' . $key, ''),
);
$form['auto_entitylabel']['auto_entitylabel_strip_' . $key] = array(
'#type' => 'checkbox',
'#title' => t('Strip HTML tags from generated title.'),
'#description' => t('Disable to prevent striping HTML tags from entity labels.'),
'#default_value' => variable_get('auto_entitylabel_strip_' . $key, 1),
);
return system_settings_form($form);
}