previously at #2724243: New para types with a paras field give "This entity (paragraph: ) cannot be referenced"

- Add a new paragraph type
* two text fields (
* two ER fields (referencing Nodes, using autocomplete)

- Attach this to a node through ERR field, using autocomplete and a custom view

- Edit preexisting node, add a new paragraph

It fails to save, saying "This entity (paragraph: ) cannot be referenced.".

If using autocomplete and/or a view is unsupported, it should not be offered.

Issue fork paragraphs-2744835

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Support from Acquia helps fund testing for Drupal Acquia logo

    Comments

    killes@www.drop.org created an issue. See original summary.

    killes@www.drop.org’s picture

    Issue summary: View changes

    Updated summary

    killes@www.drop.org’s picture

    Versions:

    paragraphs:
    8.x-1.0-rc4+52-dev

    ERR:
    8.x-1.0-rc6+8-dev

    johnchque’s picture

    Did you run all the DB updates?

    paragraphs:
    8.x-1.0-rc4+52-dev
    You mean RC5?

    Have you tried cleaning the cache?

    About autocomplete please go to 'admin/structure/types/manage/{your_content_type_name}/form-display' and select one of the select options available for the ERR Paragraphs field and save.

    killes@www.drop.org’s picture

    I guess I had RC4 installed, I updated to RC5. The bug still exists.

    all updates were run

    ran drush cache-rebuild, still not working.

    I have changed the form display to not use autocomplete. It is still not working.

    The only way to get it to work is to change the reference type to "Default" in

    admin/structure/types/manage/mynodetype/fields/node.mynodetype.field_mypara

    and not use a view.

    miro_dietiker’s picture

    Not sure what you're doing.

    You say you define a paragraph type. But then you're using ERR with autocomplete?
    So how is the paragraph content created? With previous paragraphs widget? And how you switch completely away from the paragraphs widget?

    Formally, ERR fields can support autocomplete widget. But really not when the target entity type is using the composite annotation feature.
    In that case reusing a paragraph is semantically wrong (as it is bound to the host and there can only be one).
    There is zero test coverage about this case and i think we should disallow it.
    What is the use case you have in mind that made you end up with that configuration?
    See also #2414865: [META] Reuse paragraphs / Library

    miro_dietiker’s picture

    Checked code a bit...

    A problem here is, we define a new field type based on entity reference.
    While there usually is no inheritance with plugin compatibility (formatter, widgets), we accidentally did so:
    The ERR uses the same selection plugin manager from ER, making all ER selection plugins apply to ERR.
    With our definition of a composite relationship and disallowing reuse, this seems a truly bad idea. Most ER widgets showing up will not work.

    Changing it requires us to define a new interface and switch ERR and Paragraphs to it. That's pretty ugly in the current release cycle.
    We should first discuss if this is still acceptable short before a release. But it seems we did it wrong until now..

    That said, the origin is ERR, not Paragraphs. ;-)

    Berdir’s picture

    Paragraphs does have a custom default selection handler. So I suppose what we should do is prevent you from selecting a different one. Question is, based on what? Does it really make sense based on the composite flag? What might be true for paragraphs might not be true for another entity type. Maybe we need another entity type property to set a fixed selection handler for a given entity type?

    Anyway, selecting a different selection handler is not supported, don't do that. There's no point, since you can't select anything anyway.

    But yes, selection handlers and ERR is a problem, but more in general IMHO, e.g. because there is no UI nor selection handler to deal with revsions (you can't ever select a non-default revision in the UI). But I don't think that matters for paragraphs, all we need the (default) selection handler for is validation and prevent users from selecting a different one.

    killes@www.drop.org’s picture

    Anyway, selecting a different selection handler is not supported, don't do that. There's no point, since you can't select anything anyway.

    I did realise that after a while :)

    It is just that I am accustomed to selecting a view as selector from ER fields. I don't really _need_ a view.

    I do however think that other people will also fall into that trap and something should be done about it.

    miro_dietiker’s picture

    Priority: Normal » Major

    Promoting to major to force architectural impacts discussion prior to release.

    solide-echt’s picture

    I ran into this problem myself and did some experiments.
    I run Postgres 9.5 for a database (as that sometimes matters for contribs) but I don't think it is relevant here.

    - paragraphs: 1.0
    - entity_reference_revisions: 1.0

    From what I learned the error is triggered when you have multiple references using the same widget in form display. If multiple references use different widgets no error is triggered. This behavior differs from using nodes as the master entity; in that case it is possible to use the same widget for multiple references.

    For my use case it is acceptable to change the widget for one of the relations. Nonetheless, I hope this can be solved and I'd be happy to do some further digging if that helps. Unfortunately, coding in D8 is still a bit too hard for me.

    Eric

    HLopes’s picture

    This happened to me after disabling a module that implemented behaviors.
    The paragraph type that had behaviors got deleted, and after re-adding, I had to resubmit the paragraph field settings to allow references to that paragraph type (The "Which Paragraph types should be allowed?" thingy).

    interdruper’s picture

    As @HLopes pointed out, one common reason for this error is that there has been a change in the allowed paragraph list for the field, but the edited node has non-allowed paragraph types from a past edition. If you remove them, node can be saved.

    lias’s picture

    Had the same ..."entity (paragraph: ) cannot be referenced" problem with 8.x-1.3.
    Fortunately, I still had the paragraph types and was able to recheck as available in the content type field. Then I deleted them from the node which fixed my error and then unchecked them again.
    Thanks @interdruper and @HLopes.

    rfletcher73’s picture

    I'm not sure if this is related to your issue, but i ran into the same thing today. What it happened to be was I need to go to into my custom type, manage fields, edit the paragraph field entity reference revision field. In the settings for the field you can choose what paragraph types are displayed to your content editors. Basically what you need to do is make sure that all of the paragraph types that you are using on the page you are trying to edit are checked-off on this screen. Updated that and then you can go to your page, edit it, and save it.

    Hope that helps!

    rondog469’s picture

    @HLopes was my issues. I had removed the allowed paragraph type on the content type and tried to resave an existing node.

    miro_dietiker’s picture

    As this is a repeating problem, i would propose to escalate this to core.

    Please someone open an issue in Core to ask for a more verbose error message with some explanation about the problem.