BaseAttributes
API reference › HTML Helper › Base › BaseAttributes
1 subclass
Provides reusable normalization and rendering for HTML attribute arrays.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
normalizeAttributes() static | Normalizes an array of HTML attributes into a flat associative array with processed values. | BaseAttributes |
render() static | Renders an array of HTML attributes into a string. | BaseAttributes |
Method details
Section titled “Method details”normalizeAttributes()
Section titled “normalizeAttributes() ”public static function normalizeAttributes(mixed[] $attributes, bool $encode = true): array<string, bool|string>Normalizes an array of HTML attributes into a flat associative array with processed values.
Returns a normalized array instead of an HTML string.
Parameters
| Parameter | Type | Description |
|---|---|---|
$attributes | mixed[] | Associative array of attribute names and values. |
$encode | bool | Whether to HTML-encode string values. |
Returns
array<string, bool|string>: Flat associative array with normalized values. Boolean attributes may return true.
render()
Section titled “render() ”public static function render(mixed[] $attributes): stringRenders an array of HTML attributes into a string.
Validates names, normalizes values, and returns attributes in a stable order.
Parameters
| Parameter | Type | Description |
|---|---|---|
$attributes | mixed[] | Associative array of attribute names and values. |
Returns
string: Rendered HTML attributes string.