WidgetForm   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 23 1
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
}