Error: Call to a member function getBaseFieldDefinitions() on null in Drupal\field_validation\Form\FieldValidationRuleFormBase->buildForm()

Created on 21 June 2023, over 1 year ago

Problem/Motivation

After committed the code of issue:
Drupal calls should be avoided in classes, use dependency injection instead
https://www.drupal.org/project/field_validation/issues/3363007 📌 Drupal calls should be avoided in classes, use dependency injection instead Fixed

There is a fatal error:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getBaseFieldDefinitions() on null in Drupal\field_validation\Form\FieldValidationRuleFormBase->buildForm() (line 136 of modules\field_validation\src\Form\FieldValidationRuleFormBase.php).
Drupal\field_validation\Form\FieldValidationRuleFormBase->buildForm(Array, Object, Object, 'email_field_validation_rule') (Line: 45)

it seems that $this->entityFieldManager not init in form build function.

Steps to reproduce

Proposed resolution

change it back fix this issue:
$baseFieldDefinitions = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type_id);

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇳China g089h515r806

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

Comments & Activities

Production build 0.71.5 2024