diff --git a/search_api.views.inc b/search_api.views.inc index ad1c8fd..102f0f0 100644 --- a/search_api.views.inc +++ b/search_api.views.inc @@ -689,7 +689,9 @@ function _search_api_views_get_field_handler_mapping() { // Field items have a special handler, but need a fallback handler set to be // able to optionally circumvent entity field rendering. That's why we just // set the "field_item:…" types to their fallback handlers above, along with - // non-field item types, and here post-process them to correct that. + // non-field item types, and here go through them again to add the proper + // handler ("search_api_field") under "id" and move the previous one to + // "fallback_handler". foreach ($plain_mapping as $key => $definition) { if (substr($key, 0, 11) == 'field_item:') { $plain_mapping[$key]['fallback_handler'] = $definition['id']; diff --git a/src/Plugin/views/field/SearchApiBoolean.php b/src/Plugin/views/field/SearchApiBoolean.php index 8a2dbe6..6cbf79b 100644 --- a/src/Plugin/views/field/SearchApiBoolean.php +++ b/src/Plugin/views/field/SearchApiBoolean.php @@ -17,7 +17,7 @@ use Drupal\views\Plugin\views\field\MultiItemsFieldHandlerInterface; * * @ViewsField("search_api_boolean") */ -class SearchApiBoolean extends Boolean implements MultiItemsFieldHandlerInterface{ +class SearchApiBoolean extends Boolean implements MultiItemsFieldHandlerInterface { use SearchApiFieldTrait; diff --git a/src/Plugin/views/field/SearchApiEntity.php b/src/Plugin/views/field/SearchApiEntity.php index 2f00a5d..f577606 100644 --- a/src/Plugin/views/field/SearchApiEntity.php +++ b/src/Plugin/views/field/SearchApiEntity.php @@ -93,7 +93,8 @@ class SearchApiEntity extends SearchApiStandard { $bundles = array_intersect_key($bundles, $settings['handler_settings']['target_bundles']); } foreach ($bundles as $bundle => $info) { - $view_modes[$bundle] = $this->getEntityDisplayRepository()->getViewModeOptionsByBundle($entity_type_id, $bundle); + $view_modes[$bundle] = $this->getEntityDisplayRepository() + ->getViewModeOptionsByBundle($entity_type_id, $bundle); } } diff --git a/src/Plugin/views/field/SearchApiEntityField.php b/src/Plugin/views/field/SearchApiEntityField.php index 2cc2c0c..c20837e 100644 --- a/src/Plugin/views/field/SearchApiEntityField.php +++ b/src/Plugin/views/field/SearchApiEntityField.php @@ -149,19 +149,14 @@ class SearchApiEntityField extends Field { $form[$key]['#fieldset'] = 'parent_options'; } } - // For some strange reason, the boolean formatter hard-codes the field name - // to "field_boolean", breaking our parent class's rewriteStatesSelector() - // call for fixing "#states". Therefore, we just apply that here again, with - // the hard-coded field name. + // The Core boolean formatter hard-codes the field name to "field_boolean". + // This breaks the parent class's call of rewriteStatesSelector() for fixing + // "#states". We therefore apply that behavior again here. if (!empty($form['settings'])) { FormHelper::rewriteStatesSelector($form['settings'], "fields[field_boolean][settings_edit_form]", 'options'); } - - - // Same for the options form from the fallback handler, but here we only - // add the options not already present, and put the reverse "#states" - // directive on them. + // Get the options form for the fallback handler. $fallback_form = array(); $this->fallbackHandler->buildOptionsForm($fallback_form, $form_state); // Remove all fields from FieldPluginBase from the fallback form, but leave @@ -173,7 +168,9 @@ class SearchApiEntityField extends Field { $parent_keys[] = '#pre_render'; $remove_from_fallback = array_diff_key($form, array_flip($parent_keys)); $fallback_form = array_diff_key($fallback_form, $remove_from_fallback); - + // Fix the "#states" selectors in the fallback form, and put an additional + // "#states" directive on it to only be visible for the corresponding + // "field_rendering" setting. if ($fallback_form) { FormHelper::rewriteStatesSelector($fallback_form, '"options[', '"options[fallback_options]['); $form['fallback_options'] = $fallback_form; diff --git a/src/Plugin/views/field/SearchApiStandard.php b/src/Plugin/views/field/SearchApiStandard.php index d6c5fc7..45d4966 100644 --- a/src/Plugin/views/field/SearchApiStandard.php +++ b/src/Plugin/views/field/SearchApiStandard.php @@ -17,7 +17,7 @@ use Drupal\views\Plugin\views\field\MultiItemsFieldHandlerInterface; * * @ViewsField("search_api") */ -class SearchApiStandard extends FieldPluginBase implements MultiItemsFieldHandlerInterface{ +class SearchApiStandard extends FieldPluginBase implements MultiItemsFieldHandlerInterface { use SearchApiFieldTrait;