New in Drupal 8 is the availability of form display modes. Form modes allow a site administrator to configure different field configurations for each content entity bundle edit form. In the case of nodes, you have the ability to rearrange and alter the display of fields and properties on the node edit form.
In this recipe we'll modify the default form for creating the Article content type that comes with the standard installation profile.
Enter your article text here
. Click on Update.Entities in Drupal have various view modes for each bundle. In Drupal 7 there were only display view modes, which are covered in the next recipe. Drupal 8 brings in new form modes to allow for more control of how an entity edit form is displayed.
Form display modes are configuration entities. Form display modes dictate how the DrupalCoreEntityContentEntityForm
class will build a form when an entity is edited. This will always be set to default unless changed or specified specifically to a different mode programmatically.
Since form display modes are configuration entities they can be exported using configuration management.
Hidden field properties will have no value, unless there is a provided default value. For example, if you hide the Authoring information without providing code to set a default value the content will be authored by anonymous (no user).
Form display modes for all entities are managed under one area and are enabled for each bundle type. You must first create a display mode and then it can be configured through the bundle manage interface.
In Chapter 6, Creating Forms with the Form API, we will have a recipe that details altering forms. In order to provide a default value for an entity property hidden on the form display, you will need to alter the form and provide a default value. The Field API provides a way to set a default value when fields are created.