HasType
API reference › HTML Attribute › HasType
Used by 1 type
Provides an immutable API for the type attribute of form controls.
Restricted to the <input> control types. Elements that read type as an open MIME hint declare their own setter
instead of using this trait.
See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
type() | Sets the type attribute. | HasType |
Method details
Section titled “Method details”type()
Section titled “type() ”public function type(string|Stringable|UnitEnum|null $value): staticSets the type attribute.
Restricts the value to the <input> control types. Empty and null values bypass validation and produce no
rendered attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Input control type, or null to remove the attribute. |
Returns
static: New instance with the updated type attribute. Type for predefined enum values.
Throws
InvalidArgumentException: If a non-empty value is not an<input>control type.