标签:
foreach($catetags as $cate){
echo Html::checkboxList(‘category_id‘,‘‘,$cate,[‘item‘=>‘customCheckbox‘]);
}
/**
* 自定义checkbox输出格式
*/
function customCheckbox($index, $label, $name, $checked, $value){
$cid = preg_replace(‘/-\d+/‘,‘‘,$value);
$level = preg_replace(‘/\d+-{1}/‘,‘‘,$value);
// $strpad = str_pad(‘‘, intval($level)*18," ",STR_PAD_LEFT);
$style = ‘margin-left:‘.(String)($level*20).‘px‘;
echo "<div class=‘checkcate‘ style=‘{$style}‘><label><input type=‘checkbox‘ name=‘category_id[]‘ value=‘{$cid}‘><span>{$label}</span></label></div>";
}
Yii提供的Htmler助手checkboxList可自定义Checkbox输出格式
标签:
原文地址:http://www.cnblogs.com/toward-the-sun/p/4684472.html