I've got a content type which references a taxonomy vocabulary via a multi-value field.

When I try to create a view of my content and add a taxonomy field to my view I get the following error in the console:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/ajax/add-handler/mycontent/default/field
StatusText: OK
ResponseText: Error: Unsupported operand types in Drupal\views\Plugin\views\field\FieldPluginBase->getElements() (line 314 of /var/www/html/core/modules/views/src/Plugin/views/field/FieldPluginBase.php).

Comments

mkudenko created an issue. See original summary.

mkudenko’s picture

Ok, I figured out what the actual issue was. It has nothing to do with taxonomy.

My setup is as follows:

  • Minimum profile installation
  • Site configuration is in the specified folder

After I enabled Views and Views UI, and then ran drush config-export, not all of the Views configurations were exported to my configuration folder.

Original Views config is here: /core/modules/views/config/install/views.settings.yml

Exported configuration included only the ui section. The error was occuring because the FieldPluginBase->getElements() required the field_rewrite_elements configuration.

The workaround was to copy the entire views.settings.yml file into my configuration folder and to run drush config-import.

mkudenko’s picture

Title: Unsupported operand types when adding taxonomy reference field in Views » Unsupported operand types when adding fields in Views
dawehner’s picture

OH, you ran drush config-export and it didn't exported every view? How is that even possible.

alexpott’s picture

Status: Active » Postponed (maintainer needs more info)

I've repeated the steps described in #2.
Installed minimal
Exported configuration using drush cex
Installed views_ui and views
Exported configuration using drush cex

The final drush cex made the following output:

Differences of the active config to the export directory:

 Collection  Config                        Operation
             views.settings                create
             views.view.content            create
             views.view.content_recent     create
             views.view.files              create
             views.view.user_admin_people  create
             views.view.who_s_new          create
             views.view.who_s_online       create
             views.view.glossary           create
             views.view.archive            create
             views.view.frontpage          create
             core.extension                update

Which is exactly what I would expect.

And after doing this -

diff sites/default/files/config_lxI-4QanEw4KyOoiBy5MPEQBwczzk2CA3GnbrGKuZfN-dEKa8-EMvsYryyE_hKUb3lxwkV95Yw/sync/views.settings.yml 
core/modules/views/config/install/views.settings.yml

Produces a diff of:

47,48d46
< _core:
<   default_config_hash: RaRd9EIcwA4u3qCSRLL8EnCicbda1kV__ASmVbyehvQ

Which again is exactly what I would expect.

mkudenko’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks for your help.
Turns out I didn't enable Views and ViewsUI correctly. At the time I was playing with configurations and manually added those modules to core.extension.yml just to see how that works. That enabled the modules but didn't copy the views configs.