2

is it possible to have a onepage-form for editing or creating a entry and its related (1 to n) entrys?

For example: I have a customer model, every customer can have unlimited addresses. I could now have a CustomerCrudController and a AdressCrudController with the adress having select2-field for the customer, maybe having some kind of filter for the customer in the adress-list-view but it would be a more fluid working having the ability to change or add adresses in the customers-edit-view.

Thanks Christin

4

1 回答 1

1

目前在 Backpack CRUD 创建/编辑表单中没有内置方法可以做到这一点。这是计划好的,但要等到下一版本的 Backpack 才会发生,这可能需要长达 3-6 个月的时间才能发布。

可以做的是:

1)创建您自己的自定义字段类型,例如“select_or_create_address”;

2)从 select2 字段类型开始并创建您的自定义功能:

  • 结果应该可以用ajax加载;
  • 选择旁边的按钮可以打开一个带有创建地址表单的弹出窗口,或者:
    • 您自己编写的一个快速表单,在数据库中插入一个新地址;
    • AddressCrudController 创建表单(但没有菜单、侧边栏等);为此,您需要在 AddressCrudController 中创建另一个方法,基于 CrudController::create() 但加载不同的视图;
  • 地址添加成功后,应将id作为值插入到select2中;

我的建议是使用快速表单,它应该可以更快地开发,并且您不必求助于 iFrame 弹出窗口之类的解决方案。

干杯!

于 2016-11-04T09:16:44.120 回答