|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: office-pb1 |
|
5
|
|
|
* Date: 07.07.14 |
|
6
|
|
|
* Time: 22:48 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Publication\Form; |
|
10
|
|
|
|
|
11
|
|
|
use Application\Form\Element\Image; |
|
12
|
|
|
use Phalcon\Forms\Element\Check; |
|
13
|
|
|
use Phalcon\Validation\Validator\PresenceOf; |
|
14
|
|
|
use Application\Form\Form; |
|
15
|
|
|
use Phalcon\Forms\Element\Text; |
|
16
|
|
|
use Phalcon\Forms\Element\TextArea; |
|
17
|
|
|
use Phalcon\Forms\Element\Select; |
|
18
|
|
|
use \Phalcon\Forms\Element\File; |
|
19
|
|
|
use Publication\Model\Type; |
|
20
|
|
|
|
|
21
|
|
|
class PublicationForm extends Form |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
public function initialize() |
|
25
|
|
|
{ |
|
26
|
|
|
$type = new Select('type_id', Type::cachedListArray(['key' => 'id'])); |
|
27
|
|
|
$type->setLabel('Type of Publication'); |
|
28
|
|
|
$this->add($type); |
|
29
|
|
|
|
|
30
|
|
|
$title = new Text('title', ['required' => true]); |
|
31
|
|
|
$title->addValidator(new PresenceOf([ |
|
32
|
|
|
'message' => 'Title can not be empty' |
|
33
|
|
|
])); |
|
34
|
|
|
$title->setLabel('Title'); |
|
35
|
|
|
$this->add($title); |
|
36
|
|
|
|
|
37
|
|
|
$slug = new Text('slug'); |
|
38
|
|
|
$slug->setLabel('Slug'); |
|
39
|
|
|
$this->add($slug); |
|
40
|
|
|
|
|
41
|
|
|
$date = new Text('date'); |
|
42
|
|
|
$date->setLabel('Publication Date'); |
|
43
|
|
|
$this->add($date); |
|
44
|
|
|
|
|
45
|
|
|
$text = new TextArea('text'); |
|
46
|
|
|
$text->setLabel('Text'); |
|
47
|
|
|
$this->add($text); |
|
48
|
|
|
|
|
49
|
|
|
$meta_title = new Text('meta_title', ['required' => true]); |
|
50
|
|
|
$meta_title->setLabel('meta-title'); |
|
51
|
|
|
$this->add($meta_title); |
|
52
|
|
|
|
|
53
|
|
|
$meta_description = new TextArea('meta_description', ['style' => 'height:4em; min-height: inherit']); |
|
54
|
|
|
$meta_description->setLabel('meta-description'); |
|
55
|
|
|
$this->add($meta_description); |
|
56
|
|
|
|
|
57
|
|
|
$meta_keywords = new TextArea('meta_keywords', ['style' => 'height:4em; min-height: inherit']); |
|
58
|
|
|
$meta_keywords->setLabel('meta-keywords'); |
|
59
|
|
|
$this->add($meta_keywords); |
|
60
|
|
|
|
|
61
|
|
|
$preview_inner = new Check('preview_inner'); |
|
62
|
|
|
$preview_inner->setLabel('Show preview image inside publication'); |
|
63
|
|
|
$this->add($preview_inner); |
|
64
|
|
|
|
|
65
|
|
|
$image = new Image('preview_src'); |
|
66
|
|
|
$image->setLabel('Thumbnail Image'); |
|
67
|
|
|
$this->add($image); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |