现象:
当使用when的时候,页面会输出两个id一样的元素,导致样式错乱.
if ($form->isEditing()) {
$type = $factory_code->type;
}
$form->radio('type', '类型')->options(VipFactoryCode::TYPES)
->when('=', VipFactoryCode::TYPE_LIMIT, function (Form $form) {
$form->number('limits', '限制数')->setElementName('limit-count');
})
->when('=', VipFactoryCode::TYPE_DIVISION, function (Form $form) {
$form->table('limits', '限制信息', function ($table) {
$pluck = VipFactoryProtocol::protocols();
$table->select('protocol', '协议')->options($pluck);
$table->number('limit', '数值');
$functions = VipConfig::where('key', 'sdk-functions')->value('value');
$functions = explode(',', $functions);
$functions = array_combine($functions, $functions);
$table->multipleSelect('functions', '功能')->options($functions);
});
})
->default($type);
改完之后: