-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm.php
More file actions
79 lines (71 loc) · 2.16 KB
/
Form.php
File metadata and controls
79 lines (71 loc) · 2.16 KB
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
<?php
declare(strict_types=1);
/**
* This file is part of the EaseTWBootstrap3 package
*
* https://github.com/VitexSoftware/php-ease-twbootstrap
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ease\TWB;
class Form extends \Ease\Html\Form
{
/**
* Bootstrap3 Form.
*
* @param string $properties Several tag properties. Default method is POST
* @param mixed $formContents prvky uvnitř formuláře
*/
public function __construct($properties = [], $formContents = null)
{
$properties['role'] = 'form';
parent::__construct($properties, $formContents);
$this->addTagClass('form-horizontal');
}
/**
* Vloží prvek do formuláře.
*
* @param mixed $input Vstupní prvek
* @param string $caption Popisek
* @param string $placeholder předvysvětlující text
* @param string $helptext Dodatečná nápověda
*/
public function addInput(
$input,
$caption = null,
$placeholder = null,
$helptext = null,
) {
return $this->addItem(new FormGroup(
$caption,
$input,
$placeholder,
$helptext,
));
}
/**
* Vloží další element do formuláře a upraví mu css.
*
* @param mixed $pageItem hodnota nebo EaseObjekt s metodou draw()
* @param string $pageItemName Pod tímto jménem je objekt vkládán do stromu
*
* @return pointer Odkaz na vložený objekt
*/
public function &addItem($pageItem, $pageItemName = null)
{
if (\is_object($pageItem) && method_exists($pageItem, 'setTagClass')) {
if (strtolower($pageItem->getTagType()) === 'select') {
$pageItem->setTagClass(trim(str_replace(
'form_control',
'',
$pageItem->getTagClass().' form-control',
)));
}
}
$added = parent::addItem($pageItem, $pageItemName);
return $added;
}
}