generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCanBeMultiple.php
37 lines (32 loc) · 1002 Bytes
/
CanBeMultiple.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
34
35
36
37
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute\FormControl;
/**
* Is used by widgets that implement the multiple method.
*/
trait CanBeMultiple
{
/**
* Set the multiple attribute, if set, means the user can enter comma separated email addresses in the email widget
* or can choose more than one file with the file input.
*
* @return static A new instance of the current class with the specified multiple value.
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-multiple
*/
public function multiple(): static
{
$new = clone $this;
$new->attributes['multiple'] = true;
return $new;
}
/**
* Check if the multiple attribute is set.
*
* @return bool `true` if the multiple attribute is set, `false` otherwise.
*/
public function isMultiple(): bool
{
return isset($this->attributes['multiple']) && $this->attributes['multiple'] === true;
}
}