7

I'm trying to create an entity reference field for existing paragraph, but can't seem to figure it out.

I've tried creating a normal entity reference field (content) but that only gives me the options to select from content types.

I've tried creating a paragraph field and using a entity reference view to display the results. (this displays a list of paragraph entity ids but when referencing one in a node it comes up with There are no entities matching "(21)".

How do I reference existing paragraph entities in a node?

8

Re-using paragraphs is not supported/allowed. Each paragraph has a reference to the host entity it is being used in and only supports one such reference.

If you need re-usable content in paragraphs, you need to have another entity type or bundle that you reference from a paragraph type.

  • But surely a paragraph is just an entity? And we should be able to make reference to any entity? – Janey Jul 8 '16 at 6:59
  • Yes, it is a paragraph and yes a paragraph field is nothing but a reference to it. But as I said, a paragraph also has a reference back to the entity that uses it and it currently only supports exactly one such reference. The behavior when multiple entities reference it is undefined and unsupported. – Berdir Jul 8 '16 at 14:23
  • 2
    What if the use-case isn't to re-use paragraph item but instead to reference them. My usecase is to have an eform that displays on multiple paragraph items (eform to paragraph item is one to many). The submitted entity form needs a reference back to the paragraphs item that it was on when it was submitted. This isn't re-use but is a valid use-case for referencing paragraphs items. – Frank Robert Anderson Apr 17 '17 at 23:12
  • @FrankRobertAnderson That sounds like referencing an eform from a paragraph, which I'd do as an eform paragraph type with a reference field. Knowing which paragraph, or node/host entity, the form was displayed on is something that neither paragraphs nor entity references can handle automatically, but it should be possible to do using a bit of form alter to remember the page you were on. If you need more info, ask a separate question – Berdir Apr 18 '17 at 6:06
  • 1
    @Berdir that wouldn't work for my use-case. The question is stored in the paragraph and the submission is stored in the eform submission. With your suggestion there would be no link between the question, answer, and the user that answered. But that is no matter, I have done this and it works. This wasn't an additional question, more of an argument that referencing a paragraphs item doesn't always mean reusing paragraphs content. Sometimes a reference is just a reference. – Frank Robert Anderson Apr 19 '17 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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