1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace App\Contact; |
||
6 | |||
7 | use Yiisoft\Form\FormModel; |
||
8 | use Yiisoft\Form\HtmlOptions\EmailHtmlOptions; |
||
9 | use Yiisoft\Form\HtmlOptions\RequiredHtmlOptions; |
||
10 | use Yiisoft\Validator\Rule\Email; |
||
11 | use Yiisoft\Validator\Rule\Required; |
||
12 | |||
13 | final class ContactForm extends FormModel |
||
14 | { |
||
15 | private string $name = ''; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
16 | private string $email = ''; |
||
0 ignored issues
–
show
|
|||
17 | private string $subject = ''; |
||
0 ignored issues
–
show
|
|||
18 | private string $body = ''; |
||
0 ignored issues
–
show
|
|||
19 | private ?array $attachFiles = null; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | 6 | public function getAttributeLabels(): array |
|
22 | { |
||
23 | return [ |
||
24 | 6 | 'name' => 'Name', |
|
25 | 'email' => 'Email', |
||
26 | 'subject' => 'Subject', |
||
27 | 'body' => 'Body', |
||
28 | ]; |
||
29 | } |
||
30 | |||
31 | 6 | public function getFormName(): string |
|
32 | { |
||
33 | 6 | return 'ContactForm'; |
|
34 | } |
||
35 | |||
36 | 6 | public function getRules(): array |
|
37 | { |
||
38 | return [ |
||
39 | 6 | 'name' => [new RequiredHtmlOptions(new Required())], |
|
40 | 6 | 'email' => [new RequiredHtmlOptions(new Required()), new EmailHtmlOptions(new Email())], |
|
41 | 6 | 'subject' => [new RequiredHtmlOptions(new Required())], |
|
42 | 6 | 'body' => [new RequiredHtmlOptions(new Required())], |
|
43 | ]; |
||
44 | } |
||
45 | } |
||
46 |