hook_field_formatter_settings_form
function hook_field_formatter_settings_form
hook_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)
Specify the form elements for a formatter's settings.
This hook is only invoked if hook_field_formatter_settings_summary() returns a non-empty value.
Parameters
$field: The field structure being configured.
$instance: The instance structure being configured.
$view_mode: The view 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
- modules/field_ui/field_ui.api.php, line 154
- 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' => 'textfield', '#size' => 20, '#default_value' => $settings['trim_length'], '#element_validate' => array('element_validate_integer_positive'), '#required' => TRUE, ); } return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field_ui!field_ui.api.php/function/hook_field_formatter_settings_form/7.x