diff options
Diffstat (limited to 'modules/field')
-rw-r--r-- | modules/field/field.module | 16 | ||||
-rw-r--r-- | modules/field/theme/field.tpl.php | 6 |
2 files changed, 19 insertions, 3 deletions
diff --git a/modules/field/field.module b/modules/field/field.module index 487ea3595..75dc3d431 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -756,8 +756,24 @@ function template_preprocess_field(&$variables) { ), ); $variables = array_merge($variables, $additions); + + // Initialize attributes for each item. + foreach ($variables['items'] as $delta => $item) { + $variables['item_attributes_array'][$delta] = array(); + } } /** + * Theme process function for field.tpl.php. + * + * @see field.tpl.php + */ +function template_process_field(&$variables) { + // Flatten out attributes for each item. + foreach ($variables['items'] as $delta => $item) { + $variables['item_attributes'][$delta] = drupal_attributes($variables['item_attributes_array'][$delta]); + } +} +/** * @} End of "defgroup field" */ diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php index 9018f45b5..312c4b844 100644 --- a/modules/field/theme/field.tpl.php +++ b/modules/field/theme/field.tpl.php @@ -39,13 +39,13 @@ */ ?> <?php if ($items) : ?> - <div class="field <?php print $classes; ?> clearfix"> + <div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>> <?php if (!$label_hidden) : ?> - <div class="field-label"><?php print $label ?>: </div> + <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>: </div> <?php endif; ?> <div class="field-items"> <?php foreach ($items as $delta => $item) : ?> - <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"><?php print render($item); ?></div> + <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div> <?php endforeach; ?> </div> </div> |