0

Drupal version 8.4.4

I have a paragraph type defined (For example Links), which only has one field of type link.

And I have Entity reference revisions field in my node edit form.

When I view the node i see the referenced field Label, How to make this label configurable?

3
  • Which label do you mean, of the reference field or of the field in the referenced paragraph? But both are configurable, the first in the content type and the second in the paragraph type.
    – 4uk4
    Feb 6, 2018 at 10:38
  • The referenced field should be different on different nodes Feb 6, 2018 at 11:15
  • ... different on different nodes, then this looks more like content which should be stored in a node field. Hide the label and replace it with a node field in theming.
    – 4uk4
    Feb 6, 2018 at 12:52

2 Answers 2

0

You have a few options:

  • As commented, either make it a non-paragraph field
  • Implement some custom form alter, change the the label there
  • Use two different paragraph types with a different label, allow only one of the two on each node type.
1
  • In the case three it will be limited to 2 labels which can be embedded on nodes. Feb 9, 2018 at 19:58
0

You can extend the entity with a custom class and set it as the class to use for that entity type.

Extend the Paragraph entity class and override the label() method like this:

class ParagraphExt extends Paragraph {
  function label() {
    return "your label";
  }
}

Then set it as the class to use in hook_entity_type_alter like:

function hook_entity_type_alter(array &$entity_types) {
  $entity_types['paragraph']->setClass(ParagraphExt::class);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.