Laravel Backpack关联字段含subfields时options/attribute属性失效问题
问题:Laravel Backpack带subfields的relationship字段忽略attribute/options属性
我在基于Laravel Backpack的项目中,使用以下带subfields的relationship字段配置时功能正常:
$this->crud->addField([ 'name' => 'laundryItems', 'type' => 'relationship', 'tab' => 'Pieza a enviar', 'label' => 'Piezas en el envío', // .. 'subfields' => [ [ 'name' => 'qty', 'type' => 'number', 'label' => 'Cantidad TOTAL', 'hint' => 'Total de piezas enviadas/recibidas', 'wrapper' => [ 'class' => 'form-group col-md-3', ] ], [ 'name' => 'qtyDamaged', 'type' => 'number', 'label' => 'Cantidad Dañadas', 'hint' => 'De las recibidas, cuántas dañadas', 'wrapper' => [ 'class' => 'form-group col-md-3', ] ], [ 'name' => 'qtyDirty', 'type' => 'number', 'label' => 'Cantidad Sucias', 'hint' => 'De las recibidas, cuántas sucias', 'wrapper' => [ 'class' => 'form-group col-md-3', ] ], [ 'name' => 'comment', 'label' => 'Comentario', 'type' => 'textarea', 'wrapper' => [ 'class' => 'form-group col-md-6', ], ], ], ]);
但当我尝试给这个字段添加options和attribute属性时,这两个属性完全被忽略。只有删除subfields属性后,attribute才会生效,生效的配置如下:
$this->crud->addField([ 'name' => 'laundryItems', 'type' => 'relationship', 'tab' => 'Pieza a enviar', 'label' => 'Piezas en el envío', 'attribute' => 'pmsCode', ]);
我已经清除了视图缓存,但问题依然存在。
环境版本
- PHP版本:PHP 8.2.15 (cli) (built: Jan 20 2024 14:17:05) (NTS)
- Laravel版本:10.44.0.0
- Backpack组件版本:
- backpack/backupmanager: v5.0.0
- backpack/basset: 1.2.2
- backpack/crud: 6.6.3
- backpack/devtools: 3.0.4
- backpack/editable-columns: 3.0.5
- backpack/generators: v4.0.3
- backpack/logmanager: v5.0.1
- backpack/permissionmanager: 7.1.1
- backpack/pro: 2.1.3
- backpack/settings: 3.1.0
- backpack/theme-coreuiv2: 1.2.3
- backpack/theme-coreuiv4: 1.1.1
- backpack/theme-tabler: 1.2.0
内容的提问来源于stack exchange,提问作者Miquel Ángel
相关产品推荐
相关产品推荐

