1 text.module | text_field_instance_settings_form($field, $instance) |
Implements hook_field_instance_settings_form().
File
- core/
modules/ field/ modules/ text/ text.module, line 86 - Defines simple text field types.
Code
function text_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
$fallback_format = filter_fallback_format();
$format_options = array();
foreach (filter_formats() as $format) {
$format_options[$format->format] = $format->name;
}
$format_options[$fallback_format] .= ' ' . t('(fallback format)');
$form['#element_validate'][] = 'text_field_instance_settings_form_validate';
$form['text_processing'] = array(
'#type' => 'radios',
'#title' => t('Text processing'),
'#default_value' => $settings['text_processing'],
'#options' => array(
t('Plain text'),
t('Filtered text (user selects text format)'),
),
'#weight' => -2,
);
// An empty array of formats indicates all formats are allowed.
$allowed_formats = empty($settings['allowed_formats']) ?
array_keys($format_options) : $settings['allowed_formats'];
$form['allowed_formats'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed text formats'),
'#default_value' => $allowed_formats,
'#description' => t('Choose which <a href="@text_formats">text formats</a> should be available for authors. If an author does not have permission to a format on existing content, the field will be locked.', array('@text_formats' => url('admin/config/content/formats'))),
'#options' => $format_options,
'#states' => array(
'visible' => array(
'input[name="instance[settings][text_processing]"]' => array('value' => 1),
),
),
'#weight' => -1,
);
// Display the fallback format as disabled but locked in the enabled state.
$form['allowed_formats'][$fallback_format]['#value'] = 'plain_text';
$form['allowed_formats'][$fallback_format]['#disabled'] = TRUE;
if ($field['type'] == 'text_with_summary') {
$form['display_summary'] = array(
'#type' => 'checkbox',
'#title' => t('Summary input'),
'#default_value' => $settings['display_summary'],
'#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
'#weight' => 0,
);
}
return $form;
}