Event field configuration¶
We use the Recurring Events and Field Inheritance modules to manage events.
This creates two fieldable entity types, eventseries and eventinstance,
which we customize to our needs. We try to follow a structured approach when
setting up setup of fields between the two entities.
Howto¶
Create a new event field¶
- Add a new field on the
eventseriesentity on/admin/structure/events/series/types/eventseries_type/default/edit/fields - Add a new field on the
eventinstanceentity on/admin/structure/events/instance/types/eventinstance_type/default/edit/fields. - Reuse all configuration from the field on
eventseriesincluding type, label, machine name, number of values etc. Exception: The field on theeventinstanceentity must not be required. Otherwise the Fallback strategy will not work. - Add field interitance from
eventseriestoeventinstanceon/admin/structure/field_inheritancewith the label "Event [field name]" e.g. "Event tags" and the "Fallback" inheritance strategy. - Use
eventseries,defaultand the machine name for the field as the source. - Use
eventinstance,defaultand the machine name for the field as the destination.
Render a new field¶
- Configure the display of the field for
eventserieson/admin/structure/events/series/types/eventseries_type/default/edit/display - Configure the display of the field for
eventinstanceon/admin/structure/events/instance/types/eventinstance_type/default/edit/display - Rearrange the fields such that the base field is disabled and the inherited field is displayed. This is necessary to display the inherited value from the series if there is no value on the instance but avoid rendering the value twice if the instance has a value.
- Configure the display for the inherited field on
eventinstancein the same way as the source field oneventseries. - Implement a template for the field in the theme e.g.
field--field-tags.html.twig - Create a template for the inherited field in the theme. Include the entity
type in the template name to clarify that this is used for event instances
e.g.
field--eventinstance--event-tags.html.twig. - If the field should work the same across series and instances then include
the series template in the instance template:
{{ include('field--field-tags.html.twig') }}