0

I'm creating a content type. and want to add comment for the same content on same form of add content.

I've installed Entity Reference, and selected Entity reference as Field type & selected Inline entity form - multiple values as the widget. I've chosen Selected Target type Comment under FIELD SETTINGS and I'm still not getting the comment section on content addition form.

Why is it not showing? Is there another way to show comment on content addition form?

1

Inline Entity Form doesn't support Comment forms out of the box.

Part of the process of building the IEF widget is a call to inline_entity_form_get_controller() which will retrieve a controller class from the entity metadata. As you can see in IEF's hook_entity_info_alter() invocation, it only adds this controller metadata for node, taxonomy, commerce product, & commerce line item entities.

Theoretically, you could build your own custom module that could:

  1. Invoke hook_entity_info_alter() to add support for comment entities.
  2. Build your own custom class that extends EntityInlineEntityFormController(e.g. CommentInlineEntityFormController) to be evoked for form processing.

Keep in mind this is an unusual use case, a comment entity is predicated on a its parent entity pre-existing before it's created; you're likely to run against logic that might prevent this (e.g. database integrity checks) .

It might be easier just to create your own custom node type entity that's configured just to appear like comments on your nodes.

| improve this answer | |
  • 1
    "It might be easier just to create your own custom node type entity that's configured just to appear like comments on your nodes." - this is what I would suggest. The D7 comment entity was not built very well, it was only designed to work with Nodes, and no other entity types, and it comes with all sorts of other issues. Creating new node types or entity types for comments makes them a lot easier to work with. – Jaypan Sep 8 '16 at 7:11

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.