generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HasFormtarget.php
41 lines (34 loc) · 1.04 KB
/
HasFormtarget.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
38
39
40
41
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute\FormControl;
use UIAwesome\Html\Helper\Validator;
/**
* Is used by widgets that implement the formtarget method.
*/
trait HasFormtarget
{
/**
* Specifies a browsing context name or keyword that represents the target of the control.
*
* @param string $value The browsing context name or keyword.
*
* @throws \InvalidArgumentException If the provided formtarget value is not one of the following values:
* "_blank", "_self", "_parent" or "_top".
*
* @return static A new instance of the current class with the specified formtarget value.
*/
public function formtarget(string $value): static
{
Validator::inList(
$value,
'Invalid value "%s" for the formtarget attribute. Allowed values are: "%s".',
'_blank',
'_self',
'_parent',
'_top'
);
$new = clone $this;
$new->attributes['formtarget'] = $value;
return $new;
}
}