Commit 5ff0c0d3 authored by Dries's avatar Dries

- Patch #553298 by yched, te-brian, chx, sun: redesign the 'Manage Display' screen.

parent 5d4fa6f7
......@@ -6386,6 +6386,11 @@ function entity_get_info($entity_type = NULL) {
'revision' => '',
'bundle' => '',
);
foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
$entity_info[$name]['view modes'][$view_mode] += array(
'custom settings' => FALSE,
);
}
// If no bundle key is provided, assume a single bundle, named after
// the entity type.
if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
......
......@@ -77,7 +77,7 @@ function blog_view($node, $view_mode) {
/**
* Implements hook_node_view().
*/
function blog_node_view($node, $view_mode = 'full') {
function blog_node_view($node, $view_mode) {
if ($view_mode != 'rss') {
if ($node->type == 'blog' && (arg(0) != 'blog' || arg(1) != $node->uid)) {
$links['blog_usernames_blog'] = array(
......
......@@ -240,6 +240,7 @@ function book_entity_info_alter(&$info) {
$info['node']['view modes'] += array(
'print' => array(
'label' => t('Print'),
'custom settings' => FALSE,
),
);
}
......
......@@ -279,10 +279,12 @@ function comment_update_7012() {
'label' => 'Comment',
'entity_type' => 'comment',
'settings' => array('text_processing' => 1),
// Hide field label by default.
'required' => TRUE,
'display' => array(
'full' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
),
),
);
......
......@@ -108,6 +108,7 @@ function comment_entity_info() {
'view modes' => array(
'full' => array(
'label' => t('Full comment'),
'custom settings' => FALSE,
),
),
'static cache' => FALSE,
......@@ -165,15 +166,17 @@ function comment_field_extra_fields() {
foreach (node_type_get_types() as $type) {
if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
$return['comment']['comment_node_' . $type->type] = array(
'author' => array(
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
),
'title' => array(
'label' => t('Subject'),
'description' => t('Subject textfield'),
'weight' => -1,
'form' => array(
'author' => array(
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
),
'title' => array(
'label' => t('Subject'),
'description' => t('Subject textfield'),
'weight' => -1,
),
),
);
}
......@@ -362,10 +365,11 @@ function _comment_body_field_instance_create($info) {
'bundle' => 'comment_node_' . $info->type,
'settings' => array('text_processing' => 1),
'required' => TRUE,
// Hides field label by default.
'display' => array(
'full' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
),
),
);
......
......@@ -7,55 +7,59 @@
*/
/**
* Expose "pseudo-field" components on fieldable entities.
* Exposes "pseudo-field" components on fieldable entities.
*
* Field UI's 'Manage fields' page lets users re-order fields, but also
* non-field components. For nodes, these include the title, menu settings, and
* other elements exposed by contributed modules through hook_form() and
* Field UI's "Manage fields" and "Manage display" pages let users re-order
* fields, but also non-field components. For nodes, these include the title,
* poll choices, and other elements exposed by modules through hook_form() or
* hook_form_alter().
*
* Fieldable entities or contributed modules that want to have their components
* supported should expose them using this hook, and use
* field_attach_extra_weight() to retrieve the user-defined weight when
* inserting the component.
* Fieldable entities or modules that want to have their components supported
* should expose them using this hook. The user-defined settings (weight,
* visibility) are automatically applied on rendered forms and displayed
* entities in a #pre_render callback added by field_attach_form() and
* field_attach_view().
*
* @see _field_extra_fields_pre_render()
* @see hook_field_extra_fields_alter()
*
* @return
* A nested array of 'pseudo-field' components. Each list is nested within the
* field bundle to which those components apply. The keys are the name of the
* element as it appears in the form structure. The values are arrays with the
* following key/value pairs:
* A nested array of 'pseudo-field' components. Each list is nested within
* the following keys: entity type, bundle name, context (either 'form' or
* 'display'). The keys are the name of the elements as appearing in the
* renderable array (either the entity form or the displayed entity). The
* value is an associative array:
* - label: The human readable name of the component.
* - description: A short description of the component contents.
* - weight: The default weight of the element.
* - view: (optional) The name of the element as it appears in the rendered
* structure, if different from the name in the form.
*
* @see hook_field_extra_fields_alter()
*/
function hook_field_extra_fields() {
$extra = array();
foreach (node_type_get_types() as $bundle) {
if ($type->has_title) {
$extra['node'][$bundle]['title'] = array(
'label' => $type->title_label,
'description' => t('Node module element.'),
'weight' => -5,
);
}
}
if (module_exists('poll')) {
$extra['node']['poll']['choice_wrapper'] = array(
'label' => t('Poll choices'),
'description' => t('Poll module choices.'),
'weight' => -4,
);
$extra['node']['poll']['settings'] = array(
'label' => t('Poll settings'),
'description' => t('Poll module settings.'),
'weight' => -3,
);
}
$extra['node']['poll'] = array(
'form' => array(
'choice_wrapper' => array(
'label' => t('Poll choices'),
'description' => t('Poll choices'),
'weight' => -4,
),
'settings' => array(
'label' => t('Poll settings'),
'description' => t('Poll module settings'),
'weight' => -3,
),
),
'display' => array(
'poll_view_voting' => array(
'label' => t('Poll vote'),
'description' => t('Poll vote'),
'weight' => 0,
),
'poll_view_results' => array(
'label' => t('Poll results'),
'description' => t('Poll results'),
'weight' => 0,
),
)
);
return $extra;
}
......@@ -1651,6 +1655,91 @@ function hook_field_storage_pre_query($field_name, $conditions, $options, &$skip
// @todo Needs function body.
}
/**
* Alters the display settings of a field before it gets displayed.
*
* Note that instead of hook_field_display_alter(), which is called for all
* fields on all entity types, hook_field_display_ENTITY_TYPE_alter() may be
* used to alter display settings for fields on a specific entity type only.
*
* This hook is called once per field per displayed entity. If the result of the
* hook involves reading from the database, it is highly recommended to
* statically cache the information.
*
* @param $display
* The display settings that will be used to display the field values, as
* found in the 'display' key of $instance definitions.
* @param $context
* An associative array containing:
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_ENTITY_TYPE_alter()
*/
function hook_field_display_alter(&$display, $context) {
// Leave field labels out of the search index.
// Note: The check against $context['entity_type'] == 'node' could be avoided
// by using hook_field_display_node_alter() instead of
// hook_field_display_alter(), resulting in less function calls when
// rendering non-node entities.
if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
$display['label'] = 'hidden';
}
}
/**
* Alters the display settings of a field on a given entity type before it gets displayed.
*
* Modules can implement hook_field_display_ENTITY_TYPE_alter() to alter display
* settings for fields on a specific entity type, rather than implementing
* hook_field_display_alter().
*
* This hook is called once per field per displayed entity. If the result of the
* hook involves reading from the database, it is highly recommended to
* statically cache the information.
*
* @param $display
* The display settings that will be used to display the field values, as
* found in the 'display' key of $instance definitions.
* @param $context
* An associative array containing:
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_alter()
*/
function hook_field_display_ENTITY_TYPE_alter(&$display, $context) {
// Leave field labels out of the search index.
if ($context['view_mode'] == 'search_index') {
$display['label'] = 'hidden';
}
}
/**
* Alters the display settings of pseudo-fields before an entity is displayed.
*
* This hook is called once per displayed entity. If the result of the hook
* involves reading from the database, it is highly recommended to statically
* cache the information.
*
* @param $displays
* An array of display settings for the pseudo-fields in the entity, keyed
* by pseudo-field names.
* @param $context
* An associative array containing:
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - bundle: The bundle name.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*/
function hook_field_extra_fields_display_alter(&$displays, $context) {
if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') {
$displays['description']['visibility'] = FALSE;
}
}
/**
* @} End of "ingroup field_storage"
*/
......
......@@ -552,8 +552,9 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod
// Add custom weight handling.
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$form['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
$form['#pre_render'][] = '_field_extra_weights_pre_render';
$form['#extra_fields'] = field_extra_fields($entity_type, $bundle);
$form['#pre_render'][] = '_field_extra_fields_pre_render';
$form['#entity_type'] = $entity_type;
$form['#bundle'] = $bundle;
// Save the original entity to allow later re-use.
$form_state['entity'] = $entity;
......@@ -1185,7 +1186,7 @@ function field_attach_query_revisions($field_id, $conditions, $options = array()
* @param $view_mode
* View mode, e.g. 'full', 'teaser'...
*/
function field_attach_prepare_view($entity_type, $entities, $view_mode = 'full') {
function field_attach_prepare_view($entity_type, $entities, $view_mode) {
// To ensure hooks are only run once per entity, only process items without
// the _field_view_prepared flag.
// @todo: resolve this more generally for both entity and field level hooks.
......@@ -1250,7 +1251,7 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode = 'full')
* @return
* A renderable array for the field values.
*/
function field_attach_view($entity_type, $entity, $view_mode = 'full', $langcode = NULL) {
function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL) {
// Determine the actual language to display for each field, given the
// languages available in the field data.
$display_language = field_language($entity_type, $entity, NULL, $langcode);
......@@ -1262,8 +1263,9 @@ function field_attach_view($entity_type, $entity, $view_mode = 'full', $langcode
// Add custom weight handling.
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$output['#pre_render'][] = '_field_extra_weights_pre_render';
$output['#extra_fields'] = field_extra_fields($entity_type, $bundle);
$output['#pre_render'][] = '_field_extra_fields_pre_render';
$output['#entity_type'] = $entity_type;
$output['#bundle'] = $bundle;
// Include CSS styles.
$output['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css';
......@@ -1381,6 +1383,14 @@ function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
// Clear the cache.
field_cache_clear();
// Update bundle settings.
$settings = variable_get('field_bundle_settings', array());
if (isset($settings[$entity_type][$bundle_old])) {
$settings[$entity_type][$bundle_new] = $settings[$entity_type][$bundle_old];
unset($settings[$entity_type][$bundle_old]);
variable_set('field_bundle_settings', $settings);
}
// Let other modules act on renaming the bundle.
module_invoke_all('field_attach_rename_bundle', $entity_type, $bundle_old, $bundle_new);
}
......@@ -1410,6 +1420,13 @@ function field_attach_delete_bundle($entity_type, $bundle) {
// Clear the cache.
field_cache_clear();
// Clear bundle display settings.
$settings = variable_get('field_bundle_settings', array());
if (isset($settings[$entity_type][$bundle])) {
unset($settings[$entity_type][$bundle]);
variable_set('field_bundle_settings', $settings);
}
// Let other modules act on deleting the bundle.
module_invoke_all('field_attach_delete_bundle', $entity_type, $bundle, $instances);
}
......
......@@ -31,8 +31,7 @@
* field_attach_load() then loads the 'subtitle' and 'photo' fields
* because they are both attached to the 'node' bundle 'article'.
*
* Field definitions are (currently) represented as an array of key/value
* pairs. The array properties are:
* Field definitions are represented as an array of key/value pairs.
*
* @param array $field:
* - id (integer, read-only)
......@@ -96,8 +95,7 @@
* A sub-array of key/value pairs of settings. Each storage backend
* defines and documents its own settings.
*
* Field Instance definitions are (currently) represented as an array of
* key/value pairs. The array properties are:
* Field instance definitions are represented as an array of key/value pairs.
*
* @param array $instance:
* - id (integer, read-only)
......@@ -154,11 +152,20 @@
* - module (string, read-only)
* The name of the module that implements the widget type.
* - display (array)
* A sub-array of key/value pairs identifying view modes and the way the
* field values should be displayed in each mode.
* - full (array)
* A sub-array of key/value pairs of the display options to be used
* when the field is being displayed in the "full" view mode.
* A sub-array of key/value pairs identifying the way field values should
* be displayed in each of the entity type's view modes, plus the 'default'
* mode. For each view mode, Field UI lets site administrators define
* whether they want to use a dedicated set of display options or the
* 'default' options to reduce the number of displays to maintain as they
* add new fields. For nodes, on a fresh install, only the 'teaser' view
* mode is configured to use custom display options, all other view modes
* defined use the 'default' options by default. When programmatically
* adding field instances on nodes, it is therefore recommended to at least
* specify display options for 'default' and 'teaser'.
* - default (array)
* A sub-array of key/value pairs describing the display options to be
* used when the field is being displayed in view modes that are not
* configured to use dedicated display options.
* - label (string)
* Position of the label. 'inline', 'above' and 'hidden' are the
* values recognized by the default 'field' theme implementation.
......@@ -172,7 +179,11 @@
* displayed in this view mode.
* - module (string, read-only)
* The name of the module which implements the display formatter.
* - teaser
* - some_mode
* A sub-array of key/value pairs describing the display options to be
* used when the field is being displayed in the 'some_mode' view mode.
* Those options will only be actually applied at run time if the view
* mode is not configured to use default settings for this bundle.
* - ...
* - other_mode
* - ...
......@@ -607,12 +618,16 @@ function field_delete_field($field_name) {
* - settings: each omitted setting is given the default value specified in
* hook_field_widget_info().
* - display:
* Settings for the 'full' view mode will be added, and each view mode
* will be completed with the following default values:
* Settings for the 'default' view mode will be added if not present, and
* each view mode in the definition will be completed with the following
* default values:
* - label: 'above'
* - type: the default formatter specified in hook_field_info().
* - settings: each omitted setting is given the default value specified in
* hook_field_formatter_info().
* View modes not present in the definition are left empty, and the field
* will not be displayed in this mode.
*
* @return
* The $instance array with the id property filled in.
* @throw
......@@ -730,7 +745,6 @@ function _field_write_instance($instance, $update = FALSE) {
'required' => FALSE,
'label' => $instance['field_name'],
'description' => '',
'weight' => 0,
'deleted' => 0,
);
......@@ -742,30 +756,55 @@ function _field_write_instance($instance, $update = FALSE) {
// TODO: what if no 'default_widget' specified ?
'type' => $field_type['default_widget'],
'settings' => array(),
'weight' => 0,
);
// If no weight specified, make sure the field sinks at the bottom.
if (!isset($instance['widget']['weight'])) {
$weights = array();
foreach (field_info_instances($instance['entity_type'], $instance['bundle']) as $existing_instance) {
if ($instance['field_name'] != $existing_instance['field_name']) {
$weights[] = $existing_instance['widget']['weight'];
}
}
foreach (field_extra_fields($instance['entity_type'], $instance['bundle'], 'form') as $extra) {
$weights[] = $extra['weight'];
}
$instance['widget']['weight'] = $weights ? max($weights) + 1 : 0;
}
// Check widget module.
$widget_type = field_info_widget_types($instance['widget']['type']);
$instance['widget']['module'] = $widget_type['module'];
$instance['widget']['settings'] += field_info_widget_settings($instance['widget']['type']);
// Make sure there is at least display info for the 'full' view mode.
// Make sure there are at least display settings for the 'default' view mode,
// and fill in defaults for each view mode specified in the definition.
$instance['display'] += array(
'full' => array(),
'default' => array(),
);
// Set default display settings for each view mode.
foreach ($instance['display'] as $view_mode => $display) {
$instance['display'][$view_mode] += array(
$display += array(
'label' => 'above',
// TODO: what if no 'default_formatter' specified ?
'type' => $field_type['default_formatter'],
'type' => isset($field_type['default_formatter']) ? $field_type['default_formatter'] : 'hidden',
'settings' => array(),
'weight' => 0,
);
$formatter_type = field_info_formatter_types($instance['display'][$view_mode]['type']);
// TODO : 'hidden' will raise PHP warnings.
$instance['display'][$view_mode]['module'] = $formatter_type['module'];
$instance['display'][$view_mode]['settings'] += field_info_formatter_settings($instance['display'][$view_mode]['type']);
if ($display['type'] != 'hidden') {
$formatter_type = field_info_formatter_types($display['type']);
$display['module'] = $formatter_type['module'];
$display['settings'] += field_info_formatter_settings($display['type']);
}
// If no weight specified, make sure the field sinks at the bottom.
if (!isset($display['weight'])) {
$weights = array();
foreach (field_info_instances($instance['entity_type'], $instance['bundle']) as $existing_instance) {
if ($instance['field_name'] != $existing_instance['field_name']) {
$weights[] = $existing_instance['display'][$view_mode]['weight'];
}
}
foreach (field_extra_fields($instance['entity_type'], $instance['bundle'], 'display') as $extra) {
$weights[] = $extra['display'][$view_mode]['weight'];
}
$display['weight'] = $weights ? max($weights) + 1 : 0;
}
$instance['display'][$view_mode] = $display;
}
// The serialized 'data' column contains everything from $instance that does
......
......@@ -132,7 +132,10 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances,
// Group entities, instances and items by formatter module.
$modules = array();
foreach ($instances as $id => $instance) {
$display = is_string($display) ? $instance['display'][$display] : $display;
if (is_string($display)) {
$view_mode = $display;
$display = field_get_display($instance, $view_mode);
}
if ($display['type'] !== 'hidden') {
$module = $display['module'];
$modules[$module] = $module;
......@@ -183,18 +186,13 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
// Prepare incoming display specifications.
if (is_string($display)) {
$view_mode = $display;
$display = $instance['display'][$view_mode];
$display = field_get_display($instance, $view_mode);
}
else {
$view_mode = '_custom_display';
}
if ($display['type'] !== 'hidden') {
// We never want to index fields labels.
if ($view_mode == 'search_index') {
$display['label'] = 'hidden';
}
// Calling the formatter function through module_invoke() can have a
// performance impact on pages with many fields and values.
$function = $display['module'] . '_field_formatter_view';
......
......@@ -290,11 +290,16 @@ function _field_info_prepare_instance($instance, $field) {
$instance['display'][$view_mode] = _field_info_prepare_instance_display($field, $display);
}
// Fallback to 'full' display settings for unspecified view modes.
// Fallback to 'hidden' for unspecified view modes.
$entity_info = entity_get_info($instance['entity_type']);
foreach ($entity_info['view modes'] as $view_mode => $info) {
if (!isset($instance['display'][$view_mode])) {
$instance['display'][$view_mode] = $instance['display']['full'];
$instance['display'][$view_mode] = array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
);
}
}
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
'type' => 'text_textfield',
),
'display' => array(
'full' => array(
'default' => array(
'type' => 'text_default',
),
),
......@@ -94,7 +94,12 @@ class TextFieldTestCase extends DrupalWebTestCase {
),
'widget' => array(
'type' => $widget_type,
)
),
'display' => array(
'full' => array(
'type' => 'text_default',
),
),
);
field_create_instance($this->instance);
$langcode = LANGUAGE_NONE;
......@@ -116,7 +121,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display the entity.
$entity = field_test_entity_test_load($id);
$entity->content = field_attach_view($entity_type, $entity);
$entity->content = field_attach_view($entity_type, $entity, 'full');
$this->content = drupal_render($entity->content);
$this->assertText($value, 'Filtered tags are not displayed');
}
......@@ -148,7 +153,12 @@ class TextFieldTestCase extends DrupalWebTestCase {
),
'widget' => array(
'type' => $widget_type,
)
),
'display' => array(
'full' => array(
'type' => 'text_default',
),
),
);
field_create_instance($this->instance);
$langcode = LANGUAGE_NONE;
......@@ -180,7 +190,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display the entity.
$entity = field_test_entity_test_load($id);
$entity->content = field_attach_view($entity_type, $entity);
$entity->content = field_attach_view($entity_type, $entity, 'full');
$this->content = drupal_render($entity->content);
$this->assertNoRaw($value, t('HTML tags are not displayed.'));
$this->assertRaw(check_plain($value), t('Escaped HTML is displayed correctly.'));
......@@ -213,7 +223,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display the entity.
$entity = field_test_entity_test_load($id);
$entity->content = field_attach_view($entity_type, $entity);
$entity->content = field_attach_view($entity_type, $entity, 'full');
$this->content = drupal_render($entity->content);
$this->assertRaw($value, t('Value is displayed unfiltered'));
}
......
This diff is collapsed.
......@@ -14,9 +14,11 @@ function field_test_entity_info() {
$test_entity_modes = array(
'full' => array(
'label' => t('Full object'),
'custom settings' => TRUE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => TRUE,
),
);
......
This diff is collapsed.
......@@ -16,3 +16,10 @@
padding-bottom: .5em;
}
/* Manage display */
.field-display-overview tr.region-title td {
font-weight: bold;
}
.field-display-overview tr.region-populated {
display: none;
}
......@@ -81,4 +81,143 @@ jQuery.fn.fieldPopulateOptions = function (options, selected) {
});
};
/**
* Moves a field in the display settings table from visible to hidden.
*
* This behavior is dependent on the tableDrag behavior, since it uses the
* objects initialized in that behavior to update the row.
*/
Drupal.behaviors.fieldManageDisplayDrag = {
attach: function (context, settings) {
// tableDrag is required for this behavior.
if (!$('table.field-display-overview', context).length || typeof Drupal.tableDrag == 'undefined') {
return;
}
var defaultFormatters = Drupal.settings.fieldDefaultFormatters;
var tableDrag = Drupal.tableDrag['field-display-overview'];
// Add a handler for when a row is swapped, update empty regions.
tableDrag.row.prototype.onSwap = function (swappedRow) {
checkEmptyRegions(this.table, this);
};
// Add a handler to update the formatter selector when a row is dropped in
// or out of the 'Hidden' section.
tableDrag.onDrop = function () {
var dragObject = this;
var regionRow = $(dragObject.rowObject.element).prevAll('tr.region-message').get(0);
var visibility = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
// Update the 'format' selector if the visibility changed.
var $select = $('select.field-formatter-type', dragObject.rowObject.element);
var oldVisibility = $select[0].className.replace(/([^ ]+[ ]+)*field-display-([^ ]+)([ ]+[^ ]+)*/, '$2');
if (visibility != oldVisibility) {
$select.removeClass('field-display-' + oldVisibility).addClass('field-display-' + visibility);
// Update the selected formatter if coming from an actual drag.
if (!$select.data('noUpdate')) {
if (visibility == 'visible') {
// Restore the formatter back to the previously selected one if
// available, or to the default formatter.
var value = $select.data('oldFormatter');
if (typeof value == 'undefined') {
// Extract field name from the name of the select.
var fieldName = $select[0].className.match(/\bfield-name-(\S+)\b/)[1].replace('-', '_');
// Pseudo-fields do not have an entry in the defaultFormatters
// array, we just return to 'visible' for those.
value = (fieldName in defaultFormatters) ? defaultFormatters[fieldName] : 'visible';
}
$select.data('oldFormatter', value);
}
else {
var value = 'hidden';
}
$select.val(value);
}
$select.removeData('noUpdate');
}
};
// Add the behavior to each formatter select list.
$('select.field-formatter-type', context).once('field-formatter-type', function () {
// Initialize 'previously selected formatter' as the incoming value.
if ($(this).val() != 'hidden') {
$(this).data('oldFormatter', $(this).val());
}
// Add change listener.
$(this).change(function (event) {
var $select = $(this);