dcat-admin
dcat-admin copied to clipboard
Grid->switch 会触发 form->saving 导致在saving时如有对字段操作时,字段被清空
- 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
字段中的值。
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);
});
}
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.