BHorizontalForm.php
3.45 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* CActive form with helpers to use bootstrap horizontal form
*/
class BHorizontalForm extends CActiveForm
{
public function init()
{
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' form-horizontal';
} else {
$this->htmlOptions['class'] = 'form-horizontal';
}
parent::init();
}
public function beginControlGroup($model, $attribute)
{
return '<div class="control-group' . ($model->hasErrors($attribute) ? ' error' : '') . '">' .
$this->label($model, $attribute, array('class' => 'control-label')) .
'<div class="controls">';
}
public function endControlGroup()
{
return '</div></div>';
}
public function controlGroup($model, $attribute, $controlsHtml)
{
return
$this->beginControlGroup($model, $attribute) . $controlsHtml .
$this->endControlGroup();
}
public function textAreaControlGroup($model, $attribute, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->textArea($model, $attribute, $htmlOptions));
}
public function checkBoxControlGroup($model, $attribute, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->checkBox($model, $attribute, $htmlOptions));
}
public function passwordControlGroup($model, $attribute, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->passwordField($model, $attribute, $htmlOptions));
}
public function textFieldControlGroup($model, $attribute, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->textField($model, $attribute, $htmlOptions));
}
public function listBoxControlGroup($model, $attribute, $data, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->listBox($model, $attribute, $data, $htmlOptions));
}
public function dropDownListControlGroup($model, $attribute, $data, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->dropDownList($model, $attribute, $data, $htmlOptions));
}
public function checkBoxListControlGroup($model, $attribute, $data, $htmlOptions = array())
{
$htmlOptions['separator'] = '';
$htmlOptions['template'] = '<span class="checkbox">{input} {label}</span>';
$html = '<div style="padding-top:5px; padding-left:15px;">' . $this->checkBoxList($model, $attribute, $data, $htmlOptions) . '</div>';
return $this->controlGroup($model, $attribute, $html);
}
public function fileFieldControlGroup($model, $attribute, $htmlOptions = array())
{
return $this->controlGroup($model, $attribute, $this->fileField($model, $attribute, $htmlOptions));
}
public function radioButtonListControlGroup($model, $attribute, $data, $htmlOptions = array())
{
$htmlOptions['separator'] = '';
$htmlOptions['template'] = '<span class="radio">{input} {label}</span>';
$html = '<div style="padding-top:5px; padding-left:15px;">' . $this->radioButtonList($model, $attribute, $data, $htmlOptions) . '</div>';
return $this->controlGroup($model, $attribute, $html);
}
public function beginFieldset($legend)
{
return '<fieldset><legend>' . $legend . '</legend>';
}
public function endFieldset()
{
return '</fieldset>';
}
}