It seems that Webform is only partially respecting the Webform node type's display setting for the form itself. If I go to admin/structure/types/manage/webform/display and toggle the webform "field's" format between visible and hidden, it does indeed show or hide the form on the full node view as selected. However, even when set to hidden, I see that webform_node_view() is calling drupal_get_form() and setting up a render array for it in $node->content['webform']. (I'm not sure where else in the code this is ultimately prevented from being rendered out, though.)

It's a rather unusual situation that led me to discover this - someone had set the block version of a webform to appear on that webform node's page, and then was hiding the webform itself from display. Some of the form processing was not working correctly because drupal_get_form() was being called twice for the same form; some alterations to $form during validation were ending up on the first version of the generated form, in webform_node_view(), which wasn't actually displayed, and not in the second version, in the block, which was displayed.

So I don't think solving this issue is really critical for a strange site-building scenario like this, but perhaps it would be a performance improvement not to build the form array when it won't ultimately be rendered due to the display setting?

Comments

quicksketch’s picture

Thanks, sounds like a good suggestion. I think this is because Drupal core doesn't really have enough information about what things will be returned into $node->content when hook_node_view() is called, so it generates all the content all the time and then just hides the unnecessary parts. But like you say, I think we can check the display settings and skip the processing if the display setting is set to hidden.

quicksketch’s picture

Version: 7.x-3.19 » 7.x-4.x-dev
Issue summary: View changes

Some of the form processing was not working correctly because drupal_get_form() was being called twice for the same form; some alterations to $form during validation were ending up on the first version of the generated form, in webform_node_view(), which wasn't actually displayed, and not in the second version, in the block, which was displayed.

This particular problem has been solved separately in #2215947: "Previous" button on multistep forms breaks the form when a webform is panelized.

This change might still be good to implement, but it'll likely only go in the 4.x version.

DanChadwick’s picture

Status: Active » Closed (won't fix)

Absent a patch from someone, I'm closing this as a minor issue.