目前,我有一个现有代码可以根据表 User 的 ban_time 字段将用户状态显示为“非活动”或“活动”。当用户状态为“非活动”时,ban_time 字段将按当前时间跨度更新(我猜它使用外部包装插件)
$form->field($user, 'ban_time')->widget(SwitchInput::classname(), [
'type' => SwitchInput::CHECKBOX,
'containerOptions' => ['class' => 'inner-form-group'],
'pluginOptions' => [
'state' => empty($user->ban_time),
'handleWidth' => 60,
'onText' => 'Active',
'offText' => 'Inactive'
],
'pluginEvents' => [
"switchChange.bootstrapSwitch" => "function(event, state) { $('[name=\'User[ban_time]\']').val(state ? 0 : 1) }",
]
])->label('Status');
现在,我需要添加更多状态而不是“非活动”或“活动”。所以我想将此字段更改为 dropDownList 但是在更改用户状态时,ban_time 没有更改
$form->field($user, 'ban_time')->dropDownList(
[empty($user->ban_time) =>'Active', !empty($user->ban_time) =>'Inactive']
)->label('Status');
请帮助我如何更改它