|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bone\User\Form; |
|
4
|
|
|
|
|
5
|
|
|
use Bone\I18n\Form; |
|
6
|
|
|
use Del\Form\Field\Submit; |
|
7
|
|
|
use Del\Form\Field\Text\EmailAddress; |
|
8
|
|
|
use Del\Form\Field\Text\Password; |
|
9
|
|
|
use Del\Form\Filter\Adapter\FilterAdapterZf; |
|
10
|
|
|
use Del\Form\Renderer\HorizontalFormRenderer; |
|
11
|
|
|
use Laminas\Filter\StringToLower; |
|
12
|
|
|
|
|
13
|
|
|
class RegistrationForm extends Form |
|
14
|
|
|
{ |
|
15
|
4 |
|
public function init(): void |
|
16
|
|
|
{ |
|
17
|
4 |
|
$label = $this->getTranslator()->translate('form.email.label', 'user'); |
|
18
|
4 |
|
$error = $this->getTranslator()->translate('form.email.error', 'user'); |
|
19
|
4 |
|
$placeholder = $this->getTranslator()->translate('form.email.placeholder', 'user'); |
|
|
|
|
|
|
20
|
4 |
|
$email = new EmailAddress('email'); |
|
21
|
4 |
|
$email->setRequired(true); |
|
22
|
4 |
|
$email->setAttribute('size', 40); |
|
23
|
4 |
|
$email->setId('regemail'); |
|
24
|
4 |
|
$email->setLabel($label); |
|
25
|
4 |
|
$email->setCustomErrorMessage($error); |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
4 |
|
$label = $this->getTranslator()->translate('form.password.label', 'user'); |
|
29
|
4 |
|
$error = $this->getTranslator()->translate('form.password.error', 'user'); |
|
30
|
4 |
|
$placeholder = $this->getTranslator()->translate('form.password.placeholder', 'user'); |
|
31
|
4 |
|
$password = new Password('password'); |
|
32
|
4 |
|
$password->setRequired(true); |
|
33
|
4 |
|
$password->setClass('form-control password'); |
|
34
|
4 |
|
$password->setLabel($label); |
|
35
|
4 |
|
$password->setId('regpassword'); |
|
36
|
4 |
|
$password->setAttribute('size', 40); |
|
37
|
4 |
|
$password->setAttribute('placeholder', $placeholder); |
|
38
|
4 |
|
$password->setCustomErrorMessage($error); |
|
39
|
|
|
|
|
40
|
4 |
|
$label = $this->getTranslator()->translate('form.confirm.label', 'user'); |
|
41
|
4 |
|
$error = $this->getTranslator()->translate('form.confirm.error', 'user'); |
|
42
|
4 |
|
$placeholder = $this->getTranslator()->translate('form.confirm.placeholder', 'user'); |
|
43
|
4 |
|
$confirm = new Password('confirm'); |
|
44
|
4 |
|
$confirm->setRequired(true); |
|
45
|
4 |
|
$confirm->setLabel($label); |
|
46
|
4 |
|
$confirm->setAttribute('size', 40); |
|
47
|
4 |
|
$confirm->setAttribute('placeholder', $placeholder); |
|
48
|
4 |
|
$confirm->setCustomErrorMessage($error); |
|
49
|
|
|
|
|
50
|
4 |
|
$label = $this->getTranslator()->translate('form.submit.label', 'user'); |
|
51
|
4 |
|
$submit = new Submit('submit'); |
|
52
|
4 |
|
$submit->setValue($label); |
|
53
|
4 |
|
$submit->setClass('btn btn-primary pull-right'); |
|
54
|
|
|
|
|
55
|
4 |
|
$stringToLower = new StringToLower(); |
|
56
|
4 |
|
$email->addFilter(new FilterAdapterZf($stringToLower)); |
|
57
|
|
|
|
|
58
|
4 |
|
$renderer = new HorizontalFormRenderer(); |
|
59
|
|
|
|
|
60
|
4 |
|
$this->addField($email); |
|
61
|
4 |
|
$this->addField($password); |
|
62
|
4 |
|
$this->addField($confirm); |
|
63
|
4 |
|
$this->addField($submit); |
|
64
|
4 |
|
$this->setFormRenderer($renderer); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|