Drupal fails to render correctly a webform block which is included in the computed token field on the main form.

Here are the steps to reproduce the issue:

1. Install Drupal 8: drush qd
2. Install and enable these modules: drush -y en webform block_token
3. Enable sub-modules: drush -y en webform_ui webform_examples
4. Apply patch for block_token by: cd quick-drupal-*/drupal/modules/block_token; patch -p1 < <(curl -s https://www.drupal.org/files/issues/0001-2899439-by-kenorb-Fixes-rendering-issue-for-blocks.patch)
5. Add/Place Webform block to Content region at /admin/structure/block, include Contact webform, tick 'Create the token for this block', select 'Hide for the listed pages' in Pages to hide it by default, and Save.
6. Import the following webform, or create a new one with Computed token field with block token: [block_token:webform:webform]

computed_webform:
  '#type': computed_token
  '#title': 'Computed Webform'
  '#display_on': form
  '#value': '[block_token:webform:webform]'

7. Verify the webform at: /form/computed-form

After above steps, you should see the form which includes Contact form which is rendered incorrectly (input elements are missing). See the screenshot. I've also tested different webforms, the html elements are always filtered out, despite there isn't any filter setup.

Although the form is rendered correctly at some point in Renderer.php by adding the following code in doRender:

1. Edit: core/lib/Drupal/Core/Render/Renderer.php and go to renderRoot()
2. Before final return, add this code:

echo($output); exit;

Here is the backtrace for this tokenized block, at above point when it's rendered correctly:

renderRoot()(block_token.module:60); // WORKS HERE
block_token_block_render()(block_token.module:148);
block_token_tokens()(:);
call_user_func_array()(ModuleHandler.php:402);
invokeAll()(Token.php:304);
generate()(Token.php:196);
replace()(WebformTokenManager.php:67);
replace()(WebformComputedBase.php:77);
replaceTokens()(WebformElementBase.php:661); // WORKS HERE
prepare()(WebformComputedBase.php:61);
prepare()(WebformElementManager.php:149);
invokeMethod()(WebformSubmissionForm.php:1560);
prepareElements()(WebformSubmissionForm.php:382);
form()(EntityForm.php:115);
buildForm()(WebformSubmissionForm.php:294);
buildForm()(:);
call_user_func_array()(FormBuilder.php:514);
retrieveForm()(FormBuilder.php:271);
buildForm()(EntityFormBuilder.php:48);
getForm()(Webform.php:895);
getSubmissionForm()(WebformController.php:83);
addForm()(:);
call_user_func_array()(EarlyRenderingControllerWrapperSubscriber.php:123);  // WORKS HERE
Drupal\Core\EventSubscriber\{closure}()(Renderer.php:584);
executeInRenderContext()(EarlyRenderingControllerWrapperSubscriber.php:124);
wrapControllerExecutionInRenderContext()(EarlyRenderingControllerWrapperSubscriber.php:97);
Drupal\Core\EventSubscriber\{closure}()(:);
call_user_func_array()(HttpKernel.php:144);
handleRaw()(HttpKernel.php:64);
handle()(Session.php:57);
handle()(KernelPreHandle.php:47);
handle()(PageCache.php:99);
pass()(PageCache.php:78);
handle()(ReverseProxyMiddleware.php:47);
handle()(NegotiationMiddleware.php:50);
handle()(StackedHttpKernel.php:23);
handle()(DrupalKernel.php:656);
handle()(index.php:19);
include()(d8-rs-router.php:67);

However in the final output, the block is rendered incorrectly as follow:

Computed form

Here is the generated incorrect html code:

<div id="block-webform" class="block block-webform block-webform-block">
  
      <h2>Webform</h2>
    
      <div class="content">
      






  
  




<div class="js-form-item form-item js-form-type-textfield form-type-textfield js-form-item-name form-item-name">
      




Your Name



        










        </div>








<div class="js-form-item form-item js-form-type-email form-type-email js-form-item-email form-item-email">
      




Your Email



        










        </div>








<div class="js-form-item form-item js-form-type-textfield form-type-textfield js-form-item-subject form-item-subject">
      




Subject



        










        </div>








<div class="js-form-item form-item js-form-type-textarea form-type-textarea js-form-item-message form-item-message">
      




Message



        




<div class="form-textarea-wrapper">
  
</div>




        </div>








<div data-drupal-selector="edit-actions" class="form-actions webform-actions js-form-wrapper form-wrapper" id="edit-actions">


















</div>
























  





    </div>
  </div>

which has missing input elements and lots of new line characters.

CommentFileSizeAuthor
Screen Shot 2017-08-12 at 17.12.25.png80.63 KBkenorb
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

kenorb created an issue. See original summary.

kenorb’s picture

Issue summary: View changes
kenorb’s picture

Issue summary: View changes
kenorb’s picture

Issue summary: View changes
kenorb’s picture

Issue summary: View changes
kenorb’s picture

Issue summary: View changes