如何根据数据库中的值检查复选框。如果状态(is_closed)为1,则选中要复选的复选框
echo $form->field($model, 'is_closed')->checkbox(['id'=>'checkbox-'.$value->action_status_id,'class'=>"input_class input_checkbox",'value'=>$value['is_closed'],
'onClick'=> new yii\web\JsExpression("
var tableUsed = 'status';
var obj=$(this);
var id = $(this).attr('id').split('-');
var dInput= $(this).val();
$.ajax({
type : 'POST',
data : {'id':id[1]},
url: '".Yii::$app->getUrlManager()->createUrl("actions/setting-checkbox-update")."',
success: function(data){
var tableRow = obj.closest('tr');
tableRow.find('.saving').show();
setTimeout(function(){ tableRow.find('.saving').hide();}, 500);
stat=JSON.parse(data)
tableRow.find('.input_checkbox').prop('checked', stat.closed== 1);
}
});
")])->label(FALSE);
$ value ['is_closed]根据数据库值
具有值1或0