When I try to add a comment field to a paragraph type, the comment type drop down menu shows no options at first. Eventually it seems to accept it, but when I try to display or edit a content type with paragraphs with that comment field, errors are produced. In general though, can comment fields be attached to entity types or just content types?
I'd like users to comment upon individual paragraph instances in a document for targeted content reviews.
Error msg was:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getEntityTypeId() on null in Drupal\comment\CommentForm->actions() (line 240 of core/modules/comment/src/CommentForm.php).
Comments
Comment #2
acaljuba CreditAttribution: acaljuba commentedWorking on it.
Comment #3
acaljuba CreditAttribution: acaljuba commentedI found a problem.
The reason why the comment type drop down menu shows no options is because there are no relevant comment types targeting paragraph entity type at the moment. This is what I did:
1. Create new Paragraph type.
2. Add new field. Select Comments for a field type in the following page.
3. Select the Comment type to use for your comment field.
This is where confusion occurs. Comment type drop down menu shows no available comment types targeting Paragraph Entity type, so you have to create one yourself. In the description for the drop down menu you should see 'Select the Comment type to use for this comment field. Manage the comment types from the administration overview page.'.
4. Click on the link 'administration overview page'. You'll be redirected to Comment types page.
5. Click on '+Add comment type' button to add new comment type.
6. Fill the label and description fields. In the 'Targeted entity type' section bellow select Paragraph from the drop down menu. Click Save.
Now you have Comment type that targets Paragraphs Entity type.
7. Go to Structure->Paragraphs types.
8. Search for your Paragraph type you created earlier and click on 'Manage fields' button.
9. On the page that appears, look for Options column, select 'Delete' from drop down menu in the button for the comment field you created earlier. Click Delete button on the next page.
Recreate the comment field.
10. Click on '+Add field' button to add comment field.
12. Select Comments for a field type. Click Save and continue.
11. Now, in the drop down menu you should see Comment type you created listed in the available options. Select it and click Save.
This should do it. Try recreating the content with your new Paragraph type.
Comment #4
sjpeters79 CreditAttribution: sjpeters79 commentedThanks acaljuba for providing those instructions and that worked but I'm having having an issue where the comment form is not rendering due to a missing uri on the paragraph. Does that happen for you?
Comment #5
scottsawyerI just ran into this issue. I actually have the comment form appearing in my paragraph, however, whenever a user attempts to submit the comment, I get an nginx error. Checking my log, I have:
(domains and IPs redacted)
I have a comment type assigned to Paragraph as the target entity, I have a comment field attached to a Paragraph type. I have a node with 3 instances of that paragraph type ( so, 3 comment forms on one node ).
I am wondering if this is more of a comments issue than a paragraphs issue. Paragraphs do not ( to my knowledge ) have a canonical URI, so, there would be no link template for it, and comments should have a way to manage that. I haven't looked into the comments module yet, but I would not be surprised if it does something with it's parent entity's URL.
From https://api.drupal.org/api/drupal/core%21modules%21comment%21comment.mod...
and maybe:
So, possibly this is something the comment module is not actually capable of handling. Which seems like a bug.
EDIT: Looks like my issue is related: https://www.drupal.org/project/paragraphs/issues/2878615
Comment #6
BerdirYes, this is a duplicate of #2878615: Comments + entity->uri issue. All those UX problems identifed above are about core/comments.module and have nothing to do with paragraphs specifically. You would have the same problem adding a comment field on users.
The only problem is the canonical link template and we have the other issue for that. And I also think it should be fixed in core/comment.module but that can be discussed in the other issue.
Comment #7
BerdirComment #8
pianomansam CreditAttribution: pianomansam at Rapid Development Group commentedComment #9
develop2015deepak CreditAttribution: develop2015deepak commentedAlso you can patch core entity module to from
https://www.drupal.org/project/drupal/issues/3186448#comment-13926393