jqhph / dcat-admin

🔥 基于 Laravel 的后台系统构建工具 (Laravel Admin),使用很少的代码快速构建一个功能完善的高颜值后台系统,内置丰富的后台常用组件,开箱即用,让开发者告别冗杂的HTML代码
http://www.dcatadmin.com
MIT License
3.81k stars 680 forks source link

Grid->switch 会触发 form->saving 导致在saving时如有对字段操作时,字段被清空 #2082

Closed Bossjava closed 1 month ago

Bossjava commented 8 months ago

Description:

Grid->switch 会触发 form->saving 导致在saving时如有对字段操作时,字段被清空

Steps To Reproduce:

$grid->column('status','状态')->switch();
...

 $form->saving(function (Form $form) {
                    $re = '/http.*?(\/markdown)/m';
                    $subst = 'THECDNURL$1';
                    $form->content = preg_replace($re, $subst, $form->content);
            });

在表格中点击进行switch操作,会清空content字段中的值。

lokpui commented 8 months ago

Submitted也是,有點麻煩,可以判斷有沒有request再作處理:

$form->hidden('status');

 if (!isset(request()->status)) {
            $form->saving(function (Form $form) {
                    $re = '/http.*?(\/markdown)/m';
                    $subst = 'THECDNURL$1';
                    $form->content = preg_replace($re, $subst, $form->content);
            });
}
stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.