commit b49c989e8e0bc383d83ef7059bedeaeba234bc41 Author: Joel Pittet Date: Wed May 27 19:54:57 2015 -0700 search and datetime diff --git a/core/includes/theme.inc b/core/includes/theme.inc index c9959af..f481902 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -492,29 +492,14 @@ function template_preprocess_datetime_form(&$variables) { * * @param array $variables * An associative array containing: - * - element: An associative array containing the properties of the element. - * Properties used: #title, #children, #required, #attributes. + * - title: The title text. + * - title_attributes: An Attribute object for the title element. + * - description: The help text description of the field. + * - required: A required boolean state for the date field. + * - children: The form element content. */ function template_preprocess_datetime_wrapper(&$variables) { - $element = $variables['element']; - - if (!empty($element['#title'])) { - $variables['title'] = $element['#title']; - } - - if (!empty($element['#description'])) { - $variables['description'] = $element['#description']; - } - - $variables['required'] = FALSE; - // For required datetime fields a 'form-required' class is appended to the - // label attributes. - if (!empty($element['#required'])) { - $variables['required'] = TRUE; - } - $variables['content'] = $element['#children']; - - $variables['title_attributes'] = isset($variables['title_attributes']) ? new Attribute($variables['title_attributes']) : new Attribute(); + $variables['content'] = $variables['children']; } /** @@ -1737,9 +1722,15 @@ function drupal_common_theme() { 'datetime_form' => array( 'render element' => 'element', ), - 'datetime_wrapper' => array( - 'render element' => 'element', - ), + 'datetime_wrapper' => [ + 'variables' => [ + 'title' => '', + 'title_attributes' => new Attribute(), + 'description' => '', + 'required' => FALSE, + 'children' => '', + ], + ], 'status_messages' => array( 'variables' => ['status_headings' => [], 'message_list' => NULL], ), diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php index 32d3668..1a7c434 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php @@ -11,6 +11,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Template\Attribute; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; /** @@ -28,7 +29,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // title because the actual title display is handled at a higher level by // the Field module. - $element['#theme_wrappers'][] = 'datetime_wrapper'; + $element['#theme_wrappers']['datetime_wrapper'] = [ + '#title_attributes' => new Attribute(), + ]; $element['#attributes']['class'][] = 'container-inline'; $element['value'] = array( diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 462e4db..afe514d 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -11,6 +11,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Template\Attribute; /** * Matches all 'N' Unicode character classes (numbers) @@ -103,7 +104,12 @@ function search_help($route_name, RouteMatchInterface $route_match) { function search_theme() { return array( 'search_result' => array( - 'variables' => array('result' => NULL, 'plugin_id' => NULL), + 'variables' => [ + 'result' => NULL, + 'plugin_id' => NULL, + 'title_attributes' => new Attribute(), + 'content_attributes' => new Attribute(), + ], 'file' => 'search.pages.inc', ), ); diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index dba393a..b50a6cd 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -7,7 +7,6 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Template\Attribute; /** * Implements hook_theme_suggestions_HOOK(). @@ -65,7 +64,5 @@ function template_preprocess_search_result(&$variables) { '#template' => '{{ info|safe_join(" - ") }}', '#context' => array('info' => $info), ); - $variables['title_attributes'] = isset($variables['title_attributes']) ? new Attribute($variables['title_attributes']) : new Attribute(); - $variables['content_attributes'] = isset($variables['content_attributes']) ? new Attribute($variables['content_attributes']) : new Attribute(); }