I have an existing custom module on my D9 website and I need to make some changes inside it. I want to add a field (boolean) into any content type page edit without doing it manually.

So I need my field to be available here /admin/structure/types/manage/mycontenttype/fields/add-field

On my CLI, i've run this command drush generate field, which gave me those files :


After, I ran drush updb, but it said that the database is already up to date. Yet, I don't see my field here. Moreover, the command didn't asked me what entity type should be linked to this field.

Any thoughts ? What i've done wrong ?

enter image description here

  • Why don't you use configuration management?
    – leymannx
    Nov 3, 2021 at 9:28
  • Does this answer your question? add field to user in hook_update_n
    – leymannx
    Nov 3, 2021 at 9:29
  • @leymannx because I'd like to do it programmaticaly, if it's possible. I have a certain amount of entity type, so it could be time consuming... and I don't think your solution is the same than my problem
    – mt.i.1
    Nov 3, 2021 at 9:31
  • 1
    The drush command is for modules which want to define a new field type. A prominent example is the Address module. Once you have installed such a module you see the field type on the left side, not the right. The right select box is filled with fields already used in other content types so that you can re-use them to save database tables.
    – 4uk4
    Nov 3, 2021 at 10:11
  • Oh, ok thanks for the precison ! Indeed, I see my left select dropdow.
    – mt.i.1
    Nov 3, 2021 at 11:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.