hook_entity_base_field_info not working if i enable module from Extend

Created on 28 January 2024, 11 months ago

Problem/Motivation

I use this hook_entity_base_field_info for creating a user field type boolean and it is not working if I enable the module from Extend, But it is working if I enable it from drush.

The hook does not work if Enable Single Directory Components module (Core (Experimental).

Drupal: 10.1.7
PHP: 8.1.18

Steps to reproduce

1- Enable Single Directory Components module (Core (Experimental).
2- Create a custom module and add the following code

/**
 * Implements hook_entity_base_field_info().
 */
function YOUR-MODULE_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  if ($entity_type->id() === 'user') {
    $fields['status_example'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Active'))
      ->setDescription(t('Example boolean field'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setDisplayOptions('form', [
        'type' => 'boolean_checkbox',
        'settings' => [
          'display_label' => TRUE,
        ],
      ])
      ->setDisplayConfigurable('form', TRUE);
  }

  return $fields;
}

2- try to enable the module from Extend and check on table users_field_data the column is not showing.

3- try to enable the module using drush en <YOUR-MODULE> and check on table users_field_data the column is showing.

Proposed resolution

.

Merge request link

.

Remaining tasks

.

User interface changes

.

API changes

.

Data model changes

.

Release notes snippet

.

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΈπŸ‡¦Saudi Arabia abdulaziz zaid Riyadh

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

Comments & Activities

Production build 0.71.5 2024