Score:1

Is there an alternative to hook_webform_submission_render_alter()?

br flag

In Drupal 7, I was able to use hook_webform_submission_render_alter() to alter the rendering of webform submissions. For example, I was able to completely remove the display of specific fields depending on their answered values.

I am looking to do the same in Drupal 9, where that hook no longer exist. I tried different approaches with no luck so far.

What would be the alternative to hook_webform_submission_render_alter() in Webform?

id flag
hook_webform_element_access may work for you. These are entities so do read https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/group/entity_crud/9
LeDucDuBleuet avatar
br flag
@cilefen While not being a direct alternative to hook_webform_submission_render_alter, your suggestion to use hook_webform_element_access in order to hide webform field when viewing submissions works great in that case! Thank you very much, you saved me some headaches! :-)
id flag
A more precise replacement would be one of the Entity API implementations.
Score:1
id flag

Based on your specific use case, you can use hook_webform_element_access to hide elements.

I sit in a Tesla and translated this thread with Ai:

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.