generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HasDirname.php
33 lines (28 loc) · 916 Bytes
/
HasDirname.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute\FormControl;
/**
* Is used by widgets that implement the dirname method.
*/
trait HasDirname
{
/**
* Enables submission of a value for the directionality of the element, and gives the name of the field that
* contains that value.
*
* @param string $value The name of the field that contains the directionality of the element.
*
* @return static A new instance of the current class with the specified dirname value.
*
* @link https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-dirname
*/
public function dirname(string $value): static
{
if ($value === '') {
throw new \InvalidArgumentException('The value cannot be empty.');
}
$new = clone $this;
$new->attributes['dirname'] = $value;
return $new;
}
}