Problem/Motivation
Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::get() in Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget->settingsForm()
That's because it is using get('uuid') to get a unique value for the HTML ID, but that only exists when it is a config entity.
It should use getUniqueIdentifier() instead, which exists exactly for this reason.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Original summary
Hi, I am using entity browser in drupal commerce 2 project, and when trying to add entitybrowser to pick a commerce_product_variation as widget throbber never ends.
It raises this error in error log:
2019/07/17 18:21:36 [error] 7905#7905: *112739 FastCGI sent in stderr: "PHP message: Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::get() in /drupal-project/web/modules/contrib/entity_browser/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php on line 176
#0 drupal-project/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(455): Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget->settingsForm(Array, Object(Drupal\Core\Form\FormState))
#1 drupal-project/web/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php(40): Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow(Object(Drupal\Core\Field\BaseFieldDefinition), Array, Object(Drupal\Core\Form\FormState))
#2 drupal-project/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(218): Drupal\field_ui\Form\EntityFormDisplayEditForm->buildFieldRow(Object(Drupal\Core\Field\BaseFieldDefinition), Array, Object(Drupal\Core\Form\" while reading response header from upstream, client: ******** , server: *************** , request: "POST /admin/commerce/config/order-item-types/default_order/edit/form-display?ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1", upstream: "f******", host: "************", referrer: "http://***********/admin/commerce/config/order-item-types/default_order/edit/form-display"
It works with 2.1 version
Comments
Comment #2
erik seifert commented`BaseFieldDefinition::get` is not defined. Should use `FieldDefinitionInterface::getUniqueIdentifier'
Comment #3
oknateComment #5
oknateUpdating summary, and crediting Berdir, who created a better issue name and summary in a duplicate: #3071075: Fatal error when using the entity browser widget on a base field.
Comment #6
oknateThis bug was added in #3034953: Ajax broken for Entity display plugin plugin settings.
Comment #9
oknateHere's a screenshot showing the bug on the "Authored By" field on the node entity:
It's pretty easy to confirm the fix using that field.
Here's a follow-up to add test coverage: #3071110: Add test coverage for BaseFieldDefinition fix.
Comment #11
akerbel.dev commentedI have updated the patch for 2.2.0 version.
Comment #12
akerbel.dev commentedComment #13
akerbel.dev commentedSorry, I have used a wrong branch.
Comment #14
mykola dolynskyiAlso having fatal error when changing order (in edit form) of fields defined in module of custom entity
Call to undefined method Drupal\Core\Field\BaseFieldDefinition::get() in Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget->settingsForm()Comment #15
oknateThis should be fixed (again) on the dev branch, see #3000587: the md5() and sha1() hash functions should never be used in any code.
There was a regression, due to that issue that broke this one.