8 - Manually adding a user field will delete all programmatically added user fields In my module i programmatically add user fields for the website owner instead of instructing them to do so. Here's an example of the code i used which runs in mymodule.install:

function openid_connect_entity_base_field_info(EntityTypeInterface $entity_type) {


if ($entity_type-&gt;id() === 'user') {
    $fields['field_birthdate'] = BaseFieldDefinition::create('string')
      -&gt;setLabel(t('Birthdate'))
      -&gt;setDescription(t('Add a description'))
      -&gt;setRevisionable(TRUE)
      -&gt;setTranslatable(TRUE)
      -&gt;setDisplayOptions('form', array(
        'type' =&gt; 'string_text_field',
        'weight' =&gt; 30,
        'default_value' =&gt; 0,
      ))
      -&gt;setDisplayConfigurable('form', TRUE);
  }

return fields;
}


but if you add a field manually all the programmatically added fields will be deleted as shown:

programmatically added fields before adding one manually



Adding a field manually



And boom all the programmatically fields are gone!



If this is a bug in the drupal 8 framework where do i report this?
You just need to move the hook implementation into the .module file.

It works on install in the .install file because that file is included in the request, and when Drupal looks for hook implementations, it can find it.

Wen you're not installing, e.g. when adding fields through the UI, the .install file is not included so the hook won't be found, and Drupal will consolidate the info it has by removing those fields.