2

I'm trying to learn how to configure content types and form modes programmatically in Drupal 8. I've created the following using the UI:

  • A content type named book
  • A form mode for content, named foo
  • A view mode for content, named bar

When I run drush cget, I get this list:

...
[36] core.entity_form_display.node.book.default
[37] core.entity_form_mode.node.foo
[38] core.entity_form_mode.user.register
[39] core.entity_view_display.node.book.default
[40] core.entity_view_display.node.book.teaser
[41] core.entity_view_mode.node.bar
[42] core.entity_view_mode.node.full
[43] core.entity_view_mode.node.rss
[44] core.entity_view_mode.node.search_index
[45] core.entity_view_mode.node.search_result
[46] core.entity_view_mode.node.teaser
[47] core.entity_view_mode.user.compact
[48] core.entity_view_mode.user.full
...

What is the difference between the entity_form_display configuration (36) and the entity_form_mode configurations (37, 38)?

4

entity_form_mode would be the form mode (/admin/structure/display-modes/form)

  • 37 - Form mode foo available for use on node entities (shows as content on the link above)
  • 38 - Form mode register available on user entities.

entity_form_display is the configuration for that mode on a specific bundle - how the fields are arranged (/admin/structure/types/manage/book/form-display/{form_mode}) - in your case form_mode would be foo.

  • 36 - Form display settings for the default display on the book bundle (content type) of the node entity.

The reason 36 is default is because you have arranged your form display (/admin/structure/types/manage/book/form-display) but you haven't enabled your foo mode.

At the bottom of that page is a fieldset called "Custom display settings". Expand that and you can enable your foo display for that content type.

enter image description here

In the picture, I have a created a form mode called Inline Entity Form, yours should say foo

  • Amazing! Now that I've enabled the custom display settings, I also have core.entity_form_display.node.book.foo, which I then exported with drush cget to get example code for my custom module. – rudolfbyker May 30 '18 at 21:15
  • also you can give thees from modes routs with drupal.org/project/form_mode_routing – Taggart Jensen May 30 '18 at 23:25

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.