Problem/Motivation

I created an entity type and bundle that did not have a Title field and attempted to create a view using the table format. Because views assumes Title field will be available when creating the table format, we get an error as below screenshot.

Screenshot of error caused by assumption that a Title field is available

Proposed resolution

When creating a table view, check first that the Title field exists. If not available, don't add it as a default field.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork eck-2811629

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rachel_norfolk created an issue. See original summary.

dawehner’s picture

This could also be a bug of the module you try to leverage. \Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions tries to detect which field it could use. If modules give a hint which fields should be chosen:
$default_field = $data['table']['base']['defaults']['field']; it accepts that.

rachel_norfolk’s picture

Was just ECK, really.

dawehner’s picture

"just" ECK, haha, you made my day. ECK isn't even revisionable

Version: 8.1.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
larowlan’s picture

Project: Drupal core » Entity Construction Kit (ECK)
Version: 9.3.x-dev » 8.x-1.x-dev
Component: views.module » Code
Issue tags: +Bug Smash Initiative

So the 'field' is set by this hunk in EntityViewsData


 if ($label_key = $this->entityType->getKey('label')) {
      if ($data_table) {
        $data[$views_base_table]['table']['base']['defaults'] = [
          'field' => $label_key,
          'table' => $data_table,
        ];
      }
      else {
        $data[$views_base_table]['table']['base']['defaults'] = [
          'field' => $label_key,
        ];
      }
    }

Which is correctly checking that the entity-type has a label key.

The issue is in ECK module that always tells Drupal it has a label field named title.

DieterHolvoet’s picture

I'm getting a similar error:

Error: Call to a member function getType() on null in Drupal\views\Plugin\views\field\EntityField->defineOptions() (line 370 of [..]/web/core/modules/views/src/Plugin/views/field/EntityField.php)

Removing the label entity key from the entity type definition if it isn't enabled seems to fix the issue.

DieterHolvoet’s picture

Status: Active » Needs review

osopolar made their first commit to this issue’s fork.

osopolar’s picture

I had an issue running drush simple-sitemap:rebuild-queue (drush ssr) for a eck entity related sitemap, resulting in the following error, which was hard to understand:

In Tables.php line 369:

'status' not found

In my case it was not the 'title' but the 'status' field (published => status).

Copy of patch from MR !29 attached, to be used with composer, see "Patches from drupal.org merge request URLs are dangerous?".

osopolar’s picture