实现效果
前端代码
<div class="form-group">
<label for="content" class="control-label col-xs-12 col-sm-2">用户角色:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[type]', [1=>"供应商",2=>"我是加工厂/工程商",3=>"我是施工队",4=>"个人/我要求职"], $row['type'])}
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('用户类型')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="selecttype" data-rule="required" data-source="type/index" data-field="name" class="form-control selectpage" data-multiple="true" data-params='{"wherein[type]":1}' name="row[type_ids]" type="text" value="{$row.type_ids|htmlentities}">
</div>
对应控制器的js修改
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
//selecttype 切换redio的id 点击切换改变对应的参数
$("#selecttype").data("params", function (obj) {
var type = $('input[name="row[type]"]:checked').val();
return {custom: {type: type}};
});
//清楚之前选中的值
$('input[name="row[type]"]').click(function(event) {
// 清除选择
$("#selecttype").selectPageClear();
});
}
}