WidgetForm::initialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * WidgetForm
5
 * @copyright Copyright (c) 2011 - 2013 Aleksandr Torosh (http://wezoom.com.ua)
6
 * @author Aleksandr Torosh <[email protected]>
7
 */
8
9
namespace Widget\Form;
10
11
use Phalcon\Forms\Element\Text;
12
use Phalcon\Forms\Element\TextArea;
13
14
use Application\Form\Form;
15
use Phalcon\Validation\Validator\PresenceOf;
16
use Phalcon\Validation\Validator\Regex;
17
18
class WidgetForm extends Form
19
{
20
21
    public function initialize()
22
    {
23
        $id = new Text("id");
24
        $id->addValidator(new PresenceOf(array(
25
            'message' => 'ID can not be empty.'
26
        )));
27
        $id->addValidator(new Regex(array(
28
            'pattern' => '/[a-z0-9_-]+/i',
29
            'message' => 'В ID must be a-z 0-9 _ -'
30
        )));
31
        $id->setLabel('ID');
32
33
        $title = new Text("title");
34
        $title->setLabel('Title');
35
36
        $html = new TextArea("html");
37
        $html->setLabel('HTML');
38
39
        $this->add($id);
40
        $this->add($title);
41
        $this->add($html);
42
43
    }
44
45
}