I have a custom content entity created with
public static function baseFieldDefinitions(EntityTypeInterface $entity_type).
I just added a field to that entity with
- adding a new $fields['courriel'] = BaseFieldDefinition::create('email')
- creating hook.install file with

function association_update_8101()

Running update.php has indeed added the field to the corresponding database table and I can access it with my code (for example, I store in that field a copy of user->mail.
But when I use CRUD forms for my Entity (i.e. canonical, add-form, edit-form or collection), I don't see the new field.
What did I miss?

[Edit] my hook.install is now:

function association_update_8101()
  $storage_definition = BaseFieldDefinition::create('email')
    ->setDescription(t('The email address of the Personne entity.'))
    ->installFieldStorageDefinition('courriel', 'association_personne', 'association_personne', $storage_definition);

I managed to run again update.php with success (at least with no errors): the table has now the new column (Courriel) but I still don't have my CRUD forms showing 'Courriel'.
Is there anything else I need to add to hook_update_8101 to have that done?

  • I think the problem is not in the update function itself, but it's more likely that you have a missing line. I think you can inspect what drush is doing, "drush entity updates" – Oleg Videnov Mar 20 '17 at 16:21
  • You can check also this link, with the change records. drupal.org/node/2554097 – Oleg Videnov Mar 20 '17 at 16:24
  • I updated hook_update_8101 (see Edit in my post) but still not having CRUD forms showing 'Courriel' :-( – gbmapo Mar 21 '17 at 8:03

It seems I was looking at the wrong place.
Once hook_update_8101 executed, I should have updated myEntityListBuilder.php to be consistent.
The other forms (canonical, add-form, edit-form) were effectively updated.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.