diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cd09a884f12866bacac7e3e9d0ad48c578033816..15ef789bb7e9ed300e2dc0845df65f50bcbe8aac 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2223,10 +2223,14 @@ function template_preprocess_field_multiple_value_form(&$variables) { if ($variables['multiple']) { $table_id = drupal_html_id($element['#field_name'] . '_values'); $order_class = $element['#field_name'] . '-delta-order'; + $header_attributes = new Attribute(array('class' => array('label'))); + if (!empty($element['#required'])) { + $header_attributes['class'][] = 'form-required'; + } $header = array( array( 'data' => array( - '#prefix' => '<h4 class="label">', + '#prefix' => '<h4' . $header_attributes . '>', 'title' => array( '#markup' => t($element['#title']), ), @@ -2237,12 +2241,6 @@ function template_preprocess_field_multiple_value_form(&$variables) { ), t('Order', array(), array('context' => 'Sort order')), ); - if (!empty($element['#required'])) { - $header[0]['data']['required'] = array( - '#theme' => 'form_required_marker', - '#element' => $element, - ); - } $rows = array(); // Sort items according to '_weight' (needed when the form comes back after diff --git a/core/modules/block_content/src/BlockContentViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php index 0977e9f1eb860a236c6bf24bdcf5833cb48154ea..ff2a8536b3cb56148c39823e2a5183dc8c73d945 100644 --- a/core/modules/block_content/src/BlockContentViewBuilder.php +++ b/core/modules/block_content/src/BlockContentViewBuilder.php @@ -16,6 +16,17 @@ */ class BlockContentViewBuilder extends EntityViewBuilder { + /** + * {@inheritdoc} + */ + protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { + $build = parent::getBuildDefaults($entity, $view_mode, $langcode); + // The custom block will be rendered in the wrapped block template already + // and thus has no entity template itself. + unset($build['#theme']); + return $build; + } + /** * {@inheritdoc} */ diff --git a/core/modules/contact/src/MessageViewBuilder.php b/core/modules/contact/src/MessageViewBuilder.php index 4cbbd2c172085b53e257abc977d9af72e26d711e..23e9b4300432f45292993015aa6d947273af648d 100644 --- a/core/modules/contact/src/MessageViewBuilder.php +++ b/core/modules/contact/src/MessageViewBuilder.php @@ -17,6 +17,17 @@ */ class MessageViewBuilder extends EntityViewBuilder { + /** + * {@inheritdoc} + */ + protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { + $build = parent::getBuildDefaults($entity, $view_mode, $langcode); + // The message fields are individually rendered into email templates, so + // the entity has no template itself. + unset($build['#theme']); + return $build; + } + /** * {@inheritdoc} */ diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index b0fe3050980ec9e9766ec0f3863c0bfc925f8388..58ffcde40e19c01c7aac626bdeb1199018df988b 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -64,7 +64,6 @@ function testItemList() { // Verify that title set to a render array is output. $variables = array(); $variables['title'] = array( - '#theme' => 'markup', '#markup' => '<span>Render array</span>', ); $variables['empty'] = 'No items found.'; diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php b/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php index 535faff120b975419e9958566389f464a884d968..345651254215b6c207fc526a9ca5ac8d6ca1823a 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php @@ -8,6 +8,7 @@ namespace Drupal\entity_test; use Drupal\Component\Utility\String; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityViewBuilder; /** @@ -17,6 +18,15 @@ */ class EntityTestViewBuilder extends EntityViewBuilder { + /** + * {@inheritdoc} + */ + protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { + $build = parent::getBuildDefaults($entity, $view_mode, $langcode); + unset($build['#theme']); + return $build; + } + /** * {@inheritdoc} */