From cba80407546a516ee0647cb30d9ab642e3c2c8fd Mon Sep 17 00:00:00 2001 From: Jennifer Hodgdon Date: Fri, 28 Jun 2013 11:08:20 -0700 Subject: [PATCH] Issue #2029581 by andrewmacpherson, swentel: Better examples for field formatter alter hooks --- core/modules/field_ui/field_ui.api.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php index 7bcfff01200..176993dbe0a 100644 --- a/core/modules/field_ui/field_ui.api.php +++ b/core/modules/field_ui/field_ui.api.php @@ -28,8 +28,9 @@ * @see \Drupal\field_ui\DisplayOverView. */ function hook_field_formatter_settings_form_alter(&$element, &$form_state, $context) { - // Add a 'mysetting' checkbox to the settings form for 'foo_field' fields. - if ($context['field']['type'] == 'foo_field') { + // Add a 'mysetting' checkbox to the settings form for 'foo_formatter' + // field formatters. + if ($context['formatter']->getPluginId() == 'foo_formatter') { $element['mysetting'] = array( '#type' => 'checkbox', '#title' => t('My setting'), @@ -81,9 +82,9 @@ function hook_field_widget_settings_form_alter(&$element, &$form_state, $context * @see \Drupal\field_ui\DisplayOverView. */ function hook_field_formatter_settings_summary_alter(&$summary, $context) { - // Append a message to the summary when an instance of foo_field has + // Append a message to the summary when an instance of foo_formatter has // mysetting set to TRUE for the current view mode. - if ($context['field']['type'] == 'foo_field') { + if ($context['formatter']->getPluginId() == 'foo_formatter') { if ($context['formatter']->getSetting('mysetting')) { $summary[] = t('My setting enabled.'); }