Skip to content
PHP Ecosystem
Explore

HasType

API reference › HTML Attribute › HasType

traitUIAwesome\Html\Attribute\HasType
Sourcesrc/HasType.php
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.

MethodDescriptionDefined by
type()Sets the type attribute.HasType
public function type(string|Stringable|UnitEnum|null $value): static

Sets the type attribute.

Restricts the value to the <input> control types. Empty and null values bypass validation and produce no rendered attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullInput control type, or null to remove the attribute.

Returns

static: New instance with the updated type attribute. Type for predefined enum values.

Throws