You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forms and form fields have two methods of outputting HTML attributes, $AttributesHTML and $getAttributesHTML('class'), where the 2nd example will output all attributes except the class attribute.
IIRC the reason behind this is that $AttributesHTML will call getAttributesHTML() but won’t pass through any arguments (this was an opinionated design decision in the template engine because getters traditionally shouldn’t have arguments), so it’s necessary to include the get prefix if you want arguments included.
Form is missing 'getAttributesHTML' => 'HTMLFragment' from its casting array. The AttributesHTML trait actually mentions this requirement in its documentation:
Affected Version
4.x
Description
Forms and form fields have two methods of outputting HTML attributes,
$AttributesHTML
and$getAttributesHTML('class')
, where the 2nd example will output all attributes except theclass
attribute.IIRC the reason behind this is that
$AttributesHTML
will callgetAttributesHTML()
but won’t pass through any arguments (this was an opinionated design decision in the template engine because getters traditionally shouldn’t have arguments), so it’s necessary to include theget
prefix if you want arguments included.Form
is missing'getAttributesHTML' => 'HTMLFragment'
from its casting array. TheAttributesHTML
trait actually mentions this requirement in its documentation:silverstripe-framework/src/View/AttributesHTML.php
Lines 10 to 16 in 673c114
With this casting missing, using
$getAttributesHTML('class')
on aForm
instance in templates results in escaping on quotes for the attribute valuesThe text was updated successfully, but these errors were encountered: