次のような Chtml::link があります。
echo CHtml::link('DESACTIVAR',array ('/ZfIncidencias/estado', 'id'=>$data->incidencia_id),array("class"=>"desactivar"));
これによりアクションが実行されますが、必要なのは次のとおりです。
$id_on = $data->incidencia_id;
$content_on = '<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="'.$id_on.'" checked />
<label class="onoffswitch-label" for="'.$id_on.'">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div> ';
echo CHtml::link($content_on,array('/ZfIncidencias/estado', 'id'=>$data->incidencia_id));
そして、クリックしてもアクションは実行されません。
強制的に実行する方法はありますか?
解決:
$id_off = $data->incidencia_id;?>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="<?php echo $id_off;?>" unchecked onClick="javascript:location.href = '<?php echo Yii::app()->baseUrl.'/ZfIncidencias/estado/'.$data->incidencia_id;?>'"; />
<label class="onoffswitch-label" for="<?php echo $id_off;?>">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div>