dcat-admin icon indicating copy to clipboard operation
dcat-admin copied to clipboard

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

Open Bossjava opened this issue 1 year ago • 2 comments

  • Laravel Version: 8.83.27
  • PHP Version: 8.0.26
  • Dcat Admin Version: 2.2.2 - Beta

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字段中的值。

Bossjava avatar Oct 25 '23 13:10 Bossjava

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);
            });
}

lokpui avatar Nov 01 '23 15:11 lokpui

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.

stale[bot] avatar May 02 '24 10:05 stale[bot]