How to display entity label using entity reference field checkbox form display I am working with Drupal 8. And I want to create a field of entity_reference type. The field has a reference to context_question entity. And the field is displayed fine, but without any description beside the check boxes. 

The context_question entity has a label field and I want exactly the label be displayed beside the checkbox in my first entity. What should I change in the code? Or do I need to create the fieldFormatter? 

$fields['context_question'] = BaseFieldDefinition::create('entity_reference')
  -&gt;setLabel(t('Context Question'))
  -&gt;setDescription(t('Reference to context-question-type'))
  -&gt;setSetting('target_type', 'context_question')
  -&gt;setDisplayOptions('view', array(
    'label' =&gt; 'above',   
    'format' =&gt; 'label',
    'weight' =&gt; 15,
  ))
  -&gt;setDisplayOptions('form', array(
    'type' =&gt; 'options_buttons',
    'weight' =&gt; 15,
  ))
  -&gt;setCardinality(1000)
  -&gt;setDisplayConfigurable('form', TRUE)
  -&gt;setDisplayConfigurable('view', TRUE);
I assume the context_question is your custom entity or coming from a contrib module?

There are two options:


Add label key to context_question entity definition under entity_keys so that Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection pick it up. See Aggregator item for reference.
Add a @EntityReferenceSelection plugin. You have to define one. Check TermSelection for how it is implemented for terms. It looks like this: