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