diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-07-17 19:19:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-07-17 19:19:39 +0000 |
commit | b135d644fe726e763c0a7f75ba47c4eeab4bfb88 (patch) | |
tree | cd2c1983f291527f6708606eeb8aed9e9bbaefe2 /modules/field_ui/field_ui.api.php | |
parent | ecc7ce08754ca321110c25ca29567f9726813637 (diff) | |
download | brdo-b135d644fe726e763c0a7f75ba47c4eeab4bfb88.tar.gz brdo-b135d644fe726e763c0a7f75ba47c4eeab4bfb88.tar.bz2 |
- Patch #796658 by yched, andypost: UI for field formatter settings.
Diffstat (limited to 'modules/field_ui/field_ui.api.php')
-rw-r--r-- | modules/field_ui/field_ui.api.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/modules/field_ui/field_ui.api.php b/modules/field_ui/field_ui.api.php index e224ce94e..0db4c01d3 100644 --- a/modules/field_ui/field_ui.api.php +++ b/modules/field_ui/field_ui.api.php @@ -131,6 +131,71 @@ function hook_field_widget_settings_form($field, $instance) { return $form; } + +/** + * Returns form elements for a formatter's settings. + * + * @param $field + * The field structure being configured. + * @param $instance + * The instance structure being configured. + * @param $view_mode + * The view mode being configured. + * @param $form + * The (entire) configuration form array, which will usually have no use here. + * @param $form_state + * The form state of the (entire) configuration form. + * + * @return + * The form elements for the formatter settings. + */ +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; + +} + +/** + * Returns a short summary for the current formatter settings of an instance. + * + * @param $field + * The field structure. + * @param $instance + * The instance structure. + * @param $view_mode + * The view mode for which a settings summary is requested. + * + * @return + * A string containing a short summary of the formatter settings. + */ +function hook_field_formatter_settings_summary($field, $instance, $view_mode) { + $display = $instance['display'][$view_mode]; + $settings = $display['settings']; + + $summary = ''; + + if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') { + $summary = t('Length: @chars chars', array('@chars' => $settings['trim_length'])); + } + + return $summary; +} + /** * @} End of "ingroup field_ui_field_type" */ |