1

I'm trying to figure out allow commenting on the submissions so there can be a back and forth dialog between the user and site admin(s).

In Drupal 8 webform submissions are entities (type: webform_submission) and comments are a field.

I have created a new Comment Type (webform_submission_comment) with the "Target entity type" set to webform_submission).

How do I attach a comment field to the webform_submission entity?

3

Webform submissions are content entities without Field API enabled. Comments can only be attached to fieldable entities. Webform submission data is not stored Field API, but your use case is a very reasonable example of why Field API could/should be enabled. The challenge is the UX for supporting fields, and webform elements at the same time could be overwhelming. I am not prepared to support this the core Webform module. A dedicated webform_comment.module could be created to enable Field API and might even only support for adding comments to submissions.


You are going to have use hook_entity_type_alter() to add 'field_ui_base_route' to the WebformSubmission entity.

If your content entity is fieldable, provide 'field_ui_base_route' annotation, giving the name of the route that the Manage Fields, Manage Display, and Manage Form Display pages from the Field UI module will be attached to. This is usually the bundle settings edit page, or an entity type settings page if there are no bundles.

-- https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/8.2.x

  • Thank you for the explanation. Can you offer a place to start in making the Webform submission entity fieldable? – Russell Apr 27 '18 at 21:52
  • I added some more notes to my answer. – jrockowitz Apr 28 '18 at 12:59

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.