1 <?php
2 3 4 5 6 7 8
9
10 Yii::import('bootstrap.widgets.input.BootInput');
11
12 13 14 15
16 class TbInputHorizontal extends TbInput
17 {
18 19 20
21 public function run()
22 {
23 echo CHtml::openTag('div', array('class'=>'control-group '.$this->getContainerCssClass()));
24 parent::run();
25 echo '</div>';
26 }
27
28 29 30 31
32 protected function getLabel()
33 {
34 if (isset($this->labelOptions['class']))
35 $this->labelOptions['class'] .= ' control-label';
36 else
37 $this->labelOptions['class'] = 'control-label';
38
39 return parent::getLabel();
40 }
41
42 43 44 45
46 protected function checkBox()
47 {
48 $attribute = $this->attribute;
49 echo '<div class="controls">';
50 echo '<label class="checkbox" for="'.$this->getAttributeId($attribute).'">';
51 echo $this->form->checkBox($this->model, $attribute, $this->htmlOptions).PHP_EOL;
52 echo $this->model->getAttributeLabel($attribute);
53 echo $this->getError().$this->getHint();
54 echo '</label></div>';
55 }
56
57 58 59 60
61 protected function checkBoxList()
62 {
63 echo $this->getLabel();
64 echo '<div class="controls">';
65 echo $this->form->checkBoxList($this->model, $this->attribute, $this->data, $this->htmlOptions);
66 echo $this->getError().$this->getHint();
67 echo '</div>';
68 }
69
70 71 72 73
74 protected function checkBoxListInline()
75 {
76 $this->htmlOptions['inline'] = true;
77 $this->checkBoxList();
78 }
79
80 81 82 83
84 protected function dropDownList()
85 {
86 echo $this->getLabel();
87 echo '<div class="controls">';
88 echo $this->form->dropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
89 echo $this->getError().$this->getHint();
90 echo '</div>';
91 }
92
93 94 95 96
97 protected function fileField()
98 {
99 echo $this->getLabel();
100 echo '<div class="controls">';
101 echo $this->form->fileField($this->model, $this->attribute, $this->htmlOptions);
102 echo $this->getError().$this->getHint();
103 echo '</div>';
104 }
105
106 107 108 109
110 protected function passwordField()
111 {
112 echo $this->getLabel();
113 echo '<div class="controls">';
114 echo $this->getPrepend();
115 echo $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
116 echo $this->getAppend();
117 echo $this->getError().$this->getHint();
118 echo '</div>';
119 }
120
121 122 123 124
125 protected function radioButton()
126 {
127 $attribute = $this->attribute;
128 echo '<div class="controls">';
129 echo '<label class="radio" for="'.$this->getAttributeId($attribute).'">';
130 echo $this->form->radioButton($this->model, $attribute, $this->htmlOptions).PHP_EOL;
131 echo $this->model->getAttributeLabel($attribute);
132 echo $this->getError().$this->getHint();
133 echo '</label></div>';
134 }
135
136 137 138 139
140 protected function radioButtonList()
141 {
142 echo $this->getLabel();
143 echo '<div class="controls">';
144 echo $this->form->radioButtonList($this->model, $this->attribute, $this->data, $this->htmlOptions);
145 echo $this->getError().$this->getHint();
146 echo '</div>';
147 }
148
149 150 151 152
153 protected function radioButtonListInline()
154 {
155 $this->htmlOptions['inline'] = true;
156 $this->radioButtonList();
157 }
158
159 160 161 162
163 protected function textArea()
164 {
165 echo $this->getLabel();
166 echo '<div class="controls">';
167 echo $this->form->textArea($this->model, $this->attribute, $this->htmlOptions);
168 echo $this->getError().$this->getHint();
169 echo '</div>';
170 }
171
172 173 174 175
176 protected function textField()
177 {
178 echo $this->getLabel();
179 echo '<div class="controls">';
180 echo $this->getPrepend();
181 echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
182 echo $this->getAppend();
183 echo $this->getError().$this->getHint();
184 echo '</div>';
185 }
186
187 188 189 190
191 protected function captcha()
192 {
193 echo $this->getLabel();
194 echo '<div class="controls"><div class="captcha">';
195 echo '<div class="widget">'.$this->widget('CCaptcha', $this->captchaOptions, true).'</div>';
196 echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
197 echo $this->getError().$this->getHint();
198 echo '</div></div>';
199 }
200
201 202 203 204
205 protected function uneditableField()
206 {
207 echo $this->getLabel();
208 echo '<div class="controls">';
209 echo CHtml::tag('span', $this->htmlOptions, $this->model->{$this->attribute});
210 echo $this->getError().$this->getHint();
211 echo '</div>';
212 }
213 }
214