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

Widgets / formatters should return unwrapped $elements

$
0
0

WidgetBase::form() / FormatterBase::view() both take care of nesting the generated render arrays in a wrapper keyed after the field name.

This matches the common use case of entity forms and entity views ($form['field_foo'] / $form_values['field_foo'] / $content['field_foo'])

However:
- In some other cases, that wrapper is not wanted, and needs to be manually unwrapped
- This being done in base methods, there is no guarantee that some widgets / formatters don't override it, and this results in unpredictability.

Widgets / formatters shouldn't do the wrapping themselves, they job should just be to return their own specific render array. The wrapping should be done by the calling code if needed.


Viewing all articles
Browse latest Browse all 293450

Trending Articles



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