field_ui.reference_field.html.twig

Same filename and directory in other branches
  1. 9 core/modules/help_topics/help_topics/field_ui.reference_field.html.twig
  2. 8.9.x core/modules/help_topics/help_topics/field_ui.reference_field.html.twig
  3. 10 core/modules/field_ui/help_topics/field_ui.reference_field.html.twig
---
label: 'Adding a reference field to an entity sub-type'
related:
  - core.content_structure
  - field_ui.add_field
  - field_ui.manage_display
  - field_ui.manage_form
---
{% set content_structure_topic = render_var(help_topic_link('core.content_structure')) %}
{% set content_types_link_text %}{% trans %}Content types{% endtrans %}{% endset %}
{% set content_types_link = render_var(help_route_link(content_types_link_text, 'entity.node_type.collection')) %}
<h2>{% trans %}Goal{% endtrans %}</h2>
<p>{% trans %}Add an entity reference field to an entity sub-type; see {{ content_structure_topic }} for more information on entities and reference fields.{% endtrans %}</p>
<h2>{% trans %}Steps{% endtrans %}</h2>
<ol>
  <li>{% trans %}Navigate to the page for managing the entity sub-type you want to add the field to. For example, to add a field to a content type, in the <em>Manage</em> administrative menu, navigate to <em>Structure</em> &gt; <em>{{ content_types_link }}</em>.{% endtrans %}</li>
  <li>{% trans %}Find the particular sub-type that you want to add the field to, and click <em>Manage fields</em>.{% endtrans %}</li>
  <li>{% trans %}Click <em>Add field</em>.{% endtrans %}</li>
  <li>{% trans %}In <em>Add a new field</em>, select the type of reference field you want to add. The <em>Reference</em> section of the select list shows the most common types of reference field; choose <em>Other...</em> if the entity type you want to reference is not listed.{% endtrans %}</li>
  <li>{% trans %}The <em>Label</em> field should now be visible; enter a label for the field, which is used as the field label for both content editing and content display.{% endtrans %}</li>
  <li>{% trans %}Click <em>Save and continue</em>.{% endtrans %}</li>
  <li>{% trans %}On the next screen, verify that the type of entity you want to reference is shown in <em>Type of item to reference</em>, or select it if not. Enter a value for <em>Allowed number of values</em>. You can limit the field to one value per entity item, a set number of values, or set it to have unlimited values. Click <em>Save field settings</em>.{% endtrans %}</li>
  <li>{% trans %}On the next screen, optionally edit the settings for <em>Label</em>, <em>Help text</em> (text to be displayed below the field on the content editing page), and <em>Required field</em> (to make it so a value must be entered in order to save the content when editing).{% endtrans %}</li>
  <li>{% trans %}In the <em>Reference type</em> section, you will usually want to limit the entity sub-types that can be referenced; for example, if you are creating a <em>Content</em> reference, you can check one or two <em>Content type</em> choices. The choices will be easier for content editors to scan if you also choose a sort value (normally the entity title or label field).{% endtrans %}</li>
  <li>{% trans %}Click <em>Save settings</em>. You should be returned to the <em>Manage fields</em> page, with your new field in the list.{% endtrans %}</li>
</ol>

File

core/modules/field_ui/help_topics/field_ui.reference_field.html.twig

View source
  1. ---
  2. label: 'Adding a reference field to an entity sub-type'
  3. related:
  4. - core.content_structure
  5. - field_ui.add_field
  6. - field_ui.manage_display
  7. - field_ui.manage_form
  8. ---
  9. {% set content_structure_topic = render_var(help_topic_link('core.content_structure')) %}
  10. {% set content_types_link_text %}{% trans %}Content types{% endtrans %}{% endset %}
  11. {% set content_types_link = render_var(help_route_link(content_types_link_text, 'entity.node_type.collection')) %}
  12. <h2>{% trans %}Goal{% endtrans %}</h2>
  13. <p>{% trans %}Add an entity reference field to an entity sub-type; see {{ content_structure_topic }} for more information on entities and reference fields.{% endtrans %}</p>
  14. <h2>{% trans %}Steps{% endtrans %}</h2>
  15. <ol>
  16. <li>{% trans %}Navigate to the page for managing the entity sub-type you want to add the field to. For example, to add a field to a content type, in the <em>Manage</em> administrative menu, navigate to <em>Structure</em> &gt; <em>{{ content_types_link }}</em>.{% endtrans %}</li>
  17. <li>{% trans %}Find the particular sub-type that you want to add the field to, and click <em>Manage fields</em>.{% endtrans %}</li>
  18. <li>{% trans %}Click <em>Add field</em>.{% endtrans %}</li>
  19. <li>{% trans %}In <em>Add a new field</em>, select the type of reference field you want to add. The <em>Reference</em> section of the select list shows the most common types of reference field; choose <em>Other...</em> if the entity type you want to reference is not listed.{% endtrans %}</li>
  20. <li>{% trans %}The <em>Label</em> field should now be visible; enter a label for the field, which is used as the field label for both content editing and content display.{% endtrans %}</li>
  21. <li>{% trans %}Click <em>Save and continue</em>.{% endtrans %}</li>
  22. <li>{% trans %}On the next screen, verify that the type of entity you want to reference is shown in <em>Type of item to reference</em>, or select it if not. Enter a value for <em>Allowed number of values</em>. You can limit the field to one value per entity item, a set number of values, or set it to have unlimited values. Click <em>Save field settings</em>.{% endtrans %}</li>
  23. <li>{% trans %}On the next screen, optionally edit the settings for <em>Label</em>, <em>Help text</em> (text to be displayed below the field on the content editing page), and <em>Required field</em> (to make it so a value must be entered in order to save the content when editing).{% endtrans %}</li>
  24. <li>{% trans %}In the <em>Reference type</em> section, you will usually want to limit the entity sub-types that can be referenced; for example, if you are creating a <em>Content</em> reference, you can check one or two <em>Content type</em> choices. The choices will be easier for content editors to scan if you also choose a sort value (normally the entity title or label field).{% endtrans %}</li>
  25. <li>{% trans %}Click <em>Save settings</em>. You should be returned to the <em>Manage fields</em> page, with your new field in the list.{% endtrans %}</li>
  26. </ol>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.