关于Dcat admin 动态表单的问题?
用的Dcat admin动态表单,遇到一下问题
1.字段名称不能是同一个, 必须不相同才行,我用的笨方法编辑可以新增不行
2.保存字段提示内容不存在
$type = $form->model()->type;
$form->radio('type')
->when(Config::INPUT_TYPE, function (Form $form) use ($type) {
$form->textarea($type == Config::INPUT_TYPE ? 'content' : 'content' . Config::INPUT_TYPE);
})
->when(Config::EDITOR_TYPE, function (Form $form) use ($type) {
Admin::script(<<<JS
$('.layui-layer-page').css('z-index', '1');
JS
);
$form->editor($type == Config::EDITOR_TYPE ? 'content' : 'content' . Config::EDITOR_TYPE);
})
->when(Config::IMAGE_TYPE, function (Form $form) use($type) {
$form->image($type == Config::IMAGE_TYPE ? 'content' : 'content' . Config::IMAGE_TYPE)->accept('png,jpeg,jpg')
->maxSize(1024 * 5)
->removable(false)
->retainable()
->uniqueName()
->autoUpload();
})
->options(Config::TYPE_MAPPING)
->default(Config::INPUT_TYPE);
$form->saving(function (Form $form) {
foreach (Config::TYPE_MAPPING as $k => $item) {
$content = $form->{'content'.$k};
if ($content) {
$form->content = $content;
break;
}
}
$form->deleteInput(['content1','content2', 'content3']);
dd($form->input());
});
打印结果
array:7 [
"key" => "keywords"
"description" => "seo"
"type" => "1"
"_file_" => null
"_previous_" => "http://test.my_site.com/admin/configs"
"_token" => "YMBTtTtFWm8QFimCPk5gYavtsU3oJEur3Nr3dJez"
"content" => "high refractive glass beads,all weather glass beads,MMA resin,liquid reflective film,reflective marking paint supplier"
]
但是还是报
General error: 1364 Field 'content' doesn't have a default value
各位有什么好办法来实现这个动态表单的设置吗?