1 field_ui.api.php | hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) |
Specify the form elements for a formatter's settings.
Parameters
$field: The field structure being configured.
$instance: The instance structure being configured.
$view_mode: The Display mode being configured.
$form: The (entire) configuration form array, which will usually have no use here.
$form_state: The form state of the (entire) configuration form.
Return value
The form elements for the formatter settings.:
Related topics
File
- core/
modules/ field_ui/ field_ui.api.php, line 158 - Hooks provided by the Field UI module.
Code
function hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
$element['trim_length'] = array(
'#title' => t('Length'),
'#type' => 'number',
'#size' => 20,
'#default_value' => $settings['trim_length'],
'#min' => 1,
'#required' => TRUE,
);
}
return $element;
}