AttributesHTML
trait AttributesHTML (View source)
This trait can be applied to a ViewableData class to add the logic to render attributes in an SS template.
When applying this trait to a class, you also need to add the following casting configuration.
private static $casting = [
'AttributesHTML' => 'HTMLFragment',
'getAttributesHTML' => 'HTMLFragment',
];
Methods
Set an HTML attribute
Retrieve the value of an HTML attribute
Allows customization through an 'updateAttributes' hook on the base class.
Custom attributes to process. Falls back to {@link getAttributes()}.
Details
$this
setAttribute($name, $value)
Set an HTML attribute
mixed|null
getAttribute(string $name)
Retrieve the value of an HTML attribute
array
getAttributes()
Allows customization through an 'updateAttributes' hook on the base class.
Existing attributes are passed in as the first argument and can be manipulated, but any attributes added through a subclass implementation won't be included.
string
getAttributesHTML(array $attributes = null)
Custom attributes to process. Falls back to {@link getAttributes()}.
If at least one argument is passed as a string, all arguments act as excludes, by name.