Score:0

How to associated a webform with all content of a given type— retroactively?

cn flag

The way to associate a webform with all content of a given type is to use the Webform field, and then set the default value (as far as i can tell). A bit of a problem when you already have hundreds of pieces of that content. Field Defaults saves the day— except that it does not bring in the settings for the Webform field, which is essential if you are passing a value from the content to the webform submission, which is very common. Filed this issue to address that: https://www.drupal.org/project/field_defaults/issues/3227274

Or am i missing another, better way to associate a webform with a content type?

sonfd avatar
in flag
You can write a post_update or deploy hook to update all of your existing content.
cn flag
Yep `UPDATE node__field_contact SET field_contact_default_data = "loan_officer_email: '[webform_submission:node:field_email]'" WHERE bundle='lender';` did it for me. I understand the approach "every piece of content is just a special case of some pieces of content" but seeing identical info saved in hundreds of fields in the database underscores the desirability of an approach that's pseudofield based rather than actually saving data for each field.
sonfd avatar
in flag
I would recommend doing it through the Entity, e.g. load a node then `$node->set('MY_WEBFORM_FIELD', $my_field_data); $node->save();` rather than trying to update table rows directly in the database.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.