Skip to content

11. Configuring bundles in the user interface

  • Add the following to the attributes in src/Entity/Event.php:

    field_ui_base_route: 'entity.event_type.edit_form',
  • Rebuild caches

    Run drush cache:rebuild

  • Visit /admin/structure/event-types and edit an event type.

    Note that there is a Manage fields, Manage form display and Manage display operation for each event type.

The ability to have comments is managed as a field in Drupal, so we can use Field UI to add a Comments field to an event type.

  • Add a comment type on /admin/structure/comment/types/add

    Select Event as the target entity type

  • Add a Comments field to an event type

  • Visit the Manage display page

    Note that only the Comments field appears

  • Add the following to all field definitions in the baseFieldDefinitions() method of the Event class before the semicolon:

    ->setDisplayConfigurable('view', TRUE)
  • Rebuild caches

    Run drush cache:rebuild

  • Verify that all fields now appear

  • Upload user pictures for the existing users

  • Use Rendered entity for the Attendees field on the Manage display page

  • Add a Teaser view mode on /admin/structure/display-modes/view/add/event

  • Make the Teaser view mode configurable on the event type’s Manage display page

  • Rebuild caches

    Run drush cache:rebuild

  • Configure the Teaser view mode

  • Add an Event teasers view

  • Add a Page views display with the path events

    Note that the path is entered without a leading slash in Views.

  • Use the Unformatted list style for the display

    Display Events in the Teaser view mode

  • Verify that the event teasers are displayed correctly

  • Visit the Manage form display page

    Note that only the Comments field appears

  • Add the following to all field definitions in the baseFieldDefinitions() method of the Event class before the semicolon:

    ->setDisplayConfigurable('form', TRUE)
  • Rebuild caches

    Run drush cache:rebuild

  • Note that all fields now appear

  • Configure the form display

  • Use the Select list widget for the Date field

  • Use the Check boxes/radio buttons widget for the Attendees field