Call to undefined method BundleFieldDefinition::id()

Created on 25 March 2024, over 1 year ago
Updated 3 September 2024, 11 months ago

Problem/Motivation

We define a field programmatically using "BundleFieldDefinition::create()" in hook_entity_bundle_field_info(). We don't use config. tmgmt_content doesn't like it:

Error: Call to undefined method Drupal\my_module\Field\BundleFieldDefinition::id() in tmgmt_content_form_tmgmt_settings_form_alter() (line 193 of modules/contrib/tmgmt/sources/content/tmgmt_content.module).

Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'tmgmt_settings_form') (Line: 840)
Drupal\Core\Form\FormBuilder->prepareForm('tmgmt_settings_form', Array, Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)

This is similar to this issue: https://www.drupal.org/project/ui_patterns_settings/issues/3248320 β†’

Steps to reproduce

Install commerce and its sub-module commerce_payment. Go to TMGMT settings page. See error.

Proposed resolution

Check if $storage_definition instanceof FieldStorageConfig.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Source: Entity

Created by

πŸ‡ΊπŸ‡ΈUnited States charginghawk

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

Merge Requests

Comments & Activities

  • Issue created by @charginghawk
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 8
    last update over 1 year ago
    116 pass, 2 fail
  • Pipeline finished with Failed
    over 1 year ago
    Total: 337s
    #128873
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States charginghawk
  • First commit to issue fork.
  • Status changed to Needs work 11 months ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Makes sense, but instead of the if, it's the isBaseField() ternary inside that we should check for it being a FieldStorageConfig instead.

    FWIW, I'm not sure why we even do that separation, I think we should instead just always combine entity_type_id and name together, it's also possible that there are multiple base fields with the same name.

    there's also another isBaseField() check that might also have a problem with this, because views_entity_field_label() only deals with FieldConfigInterface, so I think we should do the same and check for that interface there.

Production build 0.71.5 2024