public function render()
{
$key = array_search($this->value, $this->states);
$this->value = $key == 'on' ? 'on' : 'off';
$this->script = <<<EOT
\$('#{$this->id}_checkbox').bootstrapSwitch({
size:'small',
onSwitchChange: function(event, state) {
\$('#{$this->id}').val(state ? 'on' : 'off');
}
});;
EOT;
return parent::render();
}