48 public function run() {
50 list($name, $id) = $this->resolveNameID();
52 if ($this->hasModel()) {
54 echo $this->form->checkBox($this->model, $this->attribute, $this->htmlOptions);
56 echo CHtml::activeCheckBox($this->model, $this->attribute, $this->htmlOptions);
59 echo CHtml::checkBox($name, $this->
value, $this->htmlOptions);
73 $booster->registerPackage(
'switch');
75 $config = CJavaScript::encode($this->options);
78 echo
"$('#$id').bootstrapSwitch({$config})";
79 foreach ($this->events as $event => $handler) {
80 $event = $event.
'.bootstrapSwitch';
81 if (!$handler instanceof CJavaScriptExpression && strpos($handler,
'js:') === 0)
82 $handler =
new CJavaScriptExpression($handler);
83 echo
".on('{$event}', " . $handler .
")";
86 Yii::app()->clientScript->registerScript(__CLASS__ .
'#' . $this->getId(), ob_get_clean() .
';');