Views should require a label, rather than falling back to an unhelpful ID

Created on 10 August 2023, 11 months ago
Updated 27 September 2023, 9 months ago

Problem/Motivation

This was discovered while working on 📌 New config schema data type: `required_label` Fixed .

Views have strange behavior for labels: if the entity itself has no label, the view's ID is used as the label. That's not great, because the ID might not be as useful or descriptive as a label. And more to the point, it's inconsistent with the UI -- when you create a view as a site builder, you have to enter a label.

Proposed resolution

  1. Deprecate the logic in View::label() and trigger a deprecation error whenever the fallback logic is executed
  2. Update all test views to ensure they have labels (this is ridiculously tedious -- there's over 100 of them).
  3. Add an update path to add labels to all views which don't have one. For this case, we'll reuse the ID as the label.
  4. Change the config schema for view entities (views.view.*) so that the label property uses the new required_label data type, added in 📌 New config schema data type: `required_label` Fixed .

Remaining tasks

  1. ✅ Deprecate the logic in View::label() and trigger a deprecation error whenever the fallback logic is executed
  2. ✅ Update all test views to ensure they have labels (this is ridiculously tedious -- there's over 100 of them).
  3. ✅ Add an update path to add labels to all views which don't have one. For this case, we'll reuse the ID as the label.
  4. ✅ Change the config schema for view entities (views.view.*) so that the label property uses the new required_label data type, added in 📌 New config schema data type: `required_label` Fixed .

User interface changes

None.

API changes


The View::label() method may trigger deprecation notices in Drupal >=10.2, and will remove its fallback behavior in Drupal 11.

Data model changes

Yes: views will require labels.

Release notes snippet

TBD

📌 Task
Status

Fixed

Version

11.0 🔥

Component
Views 

Last updated less than a minute ago

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024