# HasFor

> Provides an immutable API for the for attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › HasFor

| trait | `UIAwesome\Html\Attribute\HasFor` |
| --- | --- |
| Source | [`src/HasFor.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/HasFor.php#L18) |

Used by 1 type:

- [`UIAwesome\Html\Form\Output`](/docs/extensions/html/reference/form/output/index.md)

Provides an immutable API for the `for` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/for>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`for()`](#method-for) | Sets the `for` attribute. | `HasFor` |

## Method details

### for() <span id="method-for"></span>

```php
public function for(string|Stringable|UnitEnum|null $value): static
```

Sets the `for` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Space-separated list of related IDs, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `for` attribute.