Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295092

Attributes of a block content are applied to block itself

$
0
0

If a block returns a renderable array and the array has direct attibutes they will be "stolen" from the original content and applied to the block itself.

For example a if a block returns something like this:

<?php
array(
  '#attributes' => array(
    'class' => array(
      'foo-bar'
    ),
    'data-test' => 'This is just a test'
  ),
  '#markup' => 'This is block content'
);
?>

The rendered HTML will be:

<div id="block-foobartest" class="foo-bar" data-test="This is just a test">
  This is block content.
</div>

instead of:

<div id="block-foobartest">
  <div class="content foo-bar" data-test="This is just a test">
    This is block content.
  </div>
</div>

This is especially bad for blocks that represent forms since none of the form attributes is preserved.


Viewing all articles
Browse latest Browse all 295092

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>