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

在 $form->embeds 内嵌表单中,如何使用字段动态显示功能?

Open Gwill opened this issue 2 years ago • 2 comments

  • Laravel Version: 9.5
  • PHP Version: 8.1
  • Dcat Admin Version: 2

Description:

这样写,页面上在下拉框选择不能动态显示字段:

$form->embeds('parameters', function ($form) {
    $options = [
        ...
    ];
    $form->select('type', '类型')
        ->options($options)
        ->when(1, function (Form $subform) {
            $subform->text('x');
            $subform->number('value');
        })
        ->when(2, function (Form $subform) {
            $subform->text('y');
            $subform->number('value');
        });
});

在 $form->embeds 内嵌表单中,如何使用字段动态显示功能?

Gwill avatar Mar 29 '22 08:03 Gwill

这确实是个问题,但你的写法也有点问题。 如果你选择 1,value 会被 2 的 value 覆盖 不论是选择 1 还是选择 2,两个实际上都会被执行到。

laradocs avatar Mar 30 '22 22:03 laradocs

这确实是个问题,但你的写法也有点问题。 如果你选择 1,value 会被 2 的 value 覆盖 不论是选择 1 还是选择 2,两个实际上都会被执行到。

明白,这里是个范例

Gwill avatar Mar 31 '22 01:03 Gwill

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 Sep 27 '22 05:09 stale[bot]