generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHasFormmethod.php
40 lines (33 loc) · 1.06 KB
/
HasFormmethod.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
<?php
declare(strict_types=1);
namespace UIAwesome\Html\Attribute\FormControl;
use UIAwesome\Html\Helper\Validator;
use function strtoupper;
/**
* Is used by widgets that implement the formmethod method.
*/
trait HasFormmethod
{
/**
* Set the HTTP method with which a UA is meant to associate this element for form submission.
*
* @param string $value The HTTP method with which a UA is meant to associate this element for form submission.
*
* @throws \InvalidArgumentException If the provided formmethod value is not one of the following values:
* "get", "post".
*
* @return static A new instance of the current class with the specified formmethod value.
*/
public function formmethod(string $value): static
{
Validator::inList(
strtoupper($value),
'Invalid value "%s" for the formmethod attribute. Allowed values are: "%s".',
'GET',
'POST'
);
$new = clone $this;
$new->attributes['formmethod'] = $value;
return $new;
}
}