This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Login.php
80 lines (64 loc) · 1.58 KB
/
Login.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace Application\Form;
use Zend\Form\Form;
use Zend\Form\Element;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
class Login extends Form
{
public function __construct($name = null) {
parent::__construct('login');
$this->setAttribute('method', 'post');
$username = new Element\Text('username');
$username->setLabel('Username');
$username->setAttribute('size', '32');
$this->add($username);
$password = new Element\Password('password');
$password->setLabel('Password');
$password->setAttribute('size', '10');
$this->add($password);
$csrf = new Element\Csrf('csrf');
$this->add($csrf);
$submit = new Element\Submit('submit');
$submit->setValue('Log in');
$this->add($submit);
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array(
'name' => 'username',
'requiered' => true,
'filters' => array(array('name' => 'StringTrim'),),
'validators' => array(
array(
'name' => 'StringLength',
'options' = array('min' => 8)
)
)
)));
$inputFilter->add($factory->createInput(array(
'name' => 'password',
'requiered' => true,
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'min' => 5
)
)
)
)));
$inputFilter->add($factory->createInput(array(
'name' => 'csrf',
'required' => true,
'validators' => array(
array(
'name' => 'Csrf',
'options' => array(
'timeout' => 600
)
)
)
)));
$this->setInputFilter($inputFilter);
}
}