AttributeBoolean
class AttributeBoolean extends AttributeValueBase (View source)
A class that defines a type of boolean HTML attribute.
Boolean HTML attributes are not attributes with values of TRUE/FALSE. They are attributes that if they exist in the tag, they are TRUE. Examples include selected, disabled, checked, readonly.
To set a boolean attribute on the Attribute class, set it to TRUE.
Constants
| RENDER_EMPTY_ATTRIBUTE |
Renders '$name=""' if $value is an empty string. |
Properties
| protected mixed | $value | The value itself. |
from AttributeValueBase |
| protected mixed | $name | The name of the value. |
from AttributeValueBase |
Methods
Constructs a \Drupal\Core\Template\AttributeValueBase object.
Returns a string representation of the attribute.
Implements the magic __toString() method.
Details
__construct($name, $value)
Constructs a \Drupal\Core\Template\AttributeValueBase object.
string
render()
Returns a string representation of the attribute.
While __toString only returns the value in a string form, render() contains the name of the attribute as well.
value()
Returns the raw value.
__toString()
Implements the magic __toString() method.