Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
The example code shows
'#attributes' => array(
'class' => 'accommodation',
),
I believe this should read
'#attributes' => array(
'class' => array('accommodation'),
),
Comment | File | Size | Author |
---|---|---|---|
#2 | 2903322-2.patch | 1.25 KB | gaurav.kapoor |
Comments
Comment #2
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedConverted class attributes to array and replaced old array syntax with new one.
Comment #3
levmyshkinI checked container with plain string classes in attributes and with classes in array. Both options are working. But I checked Drupal core modules and there are only classes in array:
https://api.drupal.org/api/drupal/core%21modules%21views_ui%21src%21View...
https://api.drupal.org/api/drupal/core%21modules%21field_ui%21src%21Form...
https://api.drupal.org/api/drupal/core%21modules%21field_ui%21src%21Form...
https://api.drupal.org/api/drupal/core%21modules%21media_library%21src%2...
Also as follow from this RenderElement comment:
core/lib/Drupal/Core/Render/Element/RenderElement.php
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
* - #attributes: (array) HTML attributes for the element. The first-level
* keys are the attribute names, such as 'class', and the attributes are
* usually given as an array of string values to apply to that attribute
* (the rendering system will concatenate them together into a string in
* the HTML output).
Classes should be in array. So I think we need to apply changes for comments in Container class. I'm only not sure about code style for array() or [].
Comment #4
levmyshkinComment #5
knyshuk.vova CreditAttribution: knyshuk.vova at Internetdevels, Drupal Ukraine Community commentedThe patch looks good and applies successfully. +1 for RTBC.
Comment #6
idebr CreditAttribution: idebr at ezCompany commentedComment #7
idebr CreditAttribution: idebr at ezCompany commentedClosed #3030637: Incorrect Documentation of class attributes in the Container Render Element. as a duplicate.
Comment #8
alexpottComment #9
alexpottIt does not have to be an array so this is just a task.
Committed and pushed dcf633a96c to 8.7.x and 5525420f98 to 8.6.x. Thanks!
As a docs only change backported to 8.6.x
Comment #12
idebr CreditAttribution: idebr at ezCompany commented