' . $variables['label'] . '
';
- }
-
- // Render the items.
- $output .= '';
- foreach ($variables['items'] as $delta => $item) {
- $output .= '
' . drupal_render($item, TRUE) . '
';
- }
- $output .= '
';
-
- // Render the top-level DIV.
- $output = '' . $output . '
';
-
- return $output;
-}
-
/**
* Assembles a partial entity structure with initial IDs.
*
diff --git a/core/modules/field/templates/field-multiple-value-form.html.twig b/core/modules/field/templates/field-multiple-value-form.html.twig
new file mode 100644
index 00000000000..f18a85366a1
--- /dev/null
+++ b/core/modules/field/templates/field-multiple-value-form.html.twig
@@ -0,0 +1,36 @@
+{#
+/**
+ * @file
+ * Default theme implementation for an individual form element.
+ *
+ * Available variables for all fields:
+ * - multiple: Whether there are multiple instances of the field.
+ *
+ * Available variables for single cardinality fields:
+ * - elements: Form elements to be rendered.
+ *
+ * Available variables when there are multiple fields.
+ * - table: Table of field items.
+ * - description: Description text for the form element.
+ * - button: "Add another item" button.
+ *
+ * @see template_preprocess_field_multiple_value_form()
+ *
+ * @ingroup themeable
+ */
+#}
+{% if multiple %}
+
{% if not label_hidden %}
{{ label }}:
diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme
index 642674c76aa..6b99f45d12b 100644
--- a/core/themes/bartik/bartik.theme
+++ b/core/themes/bartik/bartik.theme
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Template\RenderWrapper;
+use Drupal\Core\Template\Attribute;
/**
* Implements hook_preprocess_HOOK() for page templates.
@@ -145,27 +146,22 @@ function bartik_menu_tree__shortcut_default($variables) {
}
/**
- * Implements theme_field__field_type().
+ * Implements theme_preprocess_HOOK() for field templates.
+ *
+ * @see template_preprocess_field()
*/
-function bartik_field__taxonomy_term_reference($variables) {
- $output = '';
-
- // Render the label either as a visible list or make it visually hidden for accessibility.
- $hidden_class = empty($variables['label_hidden']) ? '' : ' visually-hidden';
- $output .= '
' . $variables['label'] . ':
';
-
- // Render the items.
- $output .= ($variables['element']['#label_display'] == 'inline') ? '
' : '';
- foreach ($variables['items'] as $delta => $item) {
- $output .= '- ' . drupal_render($item) . '
';
+function bartik_preprocess_field(&$variables) {
+ $element = $variables['element'];
+ if ($element['#field_type'] == 'taxonomy_term_reference') {
+ $label_attributes['class'] = array('field-label');
+ if ($variables['label_hidden']) {
+ $label_attributes['class'][] = 'visually-hidden';
+ }
+ if ($variables['element']['#label_display'] == 'inline') {
+ $label_attributes['class'][] = 'inline';
+ }
+ $variables['label_attributes'] = new Attribute($label_attributes);
}
- $output .= '
';
-
- // Render the top-level DIV.
- $variables['attributes']['class'][] = 'clearfix';
- $output = '' . $output . '
';
-
- return $output;
}
/**
diff --git a/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig
new file mode 100644
index 00000000000..f09143ed487
--- /dev/null
+++ b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig
@@ -0,0 +1,28 @@
+{#
+/**
+ * @file
+ * Bartik theme override for taxonomy term fields.
+ *
+ * Available variables:
+ * - attributes: HTML attributes for the containing element.
+ * - label_hidden: Whether the field label has been set to hidden.
+ * - label_attributes: HTML attributes for the label.
+ * - label: The label for the field.
+ * - content_attributes: HTML attributes for the content.
+ * - items: List of all the field items.
+ * - item_attributes: HTML attributes for each item.
+ *
+ * @see template_preprocess_field()
+ * @see bartik_preprocess_field()
+ *
+ * @ingroup themeable
+ */
+#}
+
+
{{ label }}:
+
+ {% for delta, item in items %}
+ - {{ item }}
+ {% endfor %}
+
+