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

hasMany中使用map组件异常

Open Lexluth0r opened this issue 4 years ago • 4 comments

  • Laravel Version: 8.0
  • PHP Version: 7.4
  • Dcat Admin Version: 2.0.19-beta

Description:

在hasMany中使用map组件时会报错误

htmlspecialchars() expects parameter 1 to be string, array given

Steps To Reproduce:

Lexluth0r avatar Feb 22 '21 06:02 Lexluth0r

看了下源码应该是在 NestedForm 中 setElementClass 造成的, https://github.com/jqhph/dcat-admin/blob/7b58de449a577c8c68a30e1d2e61f09b8e2bff87/src/Form/NestedForm.php#L379 因为 setElementClass 之后,在Field中便不会调用map类的 getDefaultElementClass 方法, https://github.com/jqhph/dcat-admin/blob/7b58de449a577c8c68a30e1d2e61f09b8e2bff87/src/Form/Field/Map.php#L113 导致map的渲染时 $class 为数组报错。 https://github.com/jqhph/dcat-admin/blob/7b58de449a577c8c68a30e1d2e61f09b8e2bff87/resources/views/form/map.blade.php#L22 @jqhph 希望提供暂时处理方法。

Lexluth0r avatar Feb 23 '21 02:02 Lexluth0r

你可以自己先试试重写Map类的setElementClass方法

jqhph avatar Feb 23 '21 02:02 jqhph

你可以自己先试试重写Map类的setElementClass方法

多谢回复,重写 Map 类的 setElementClass 方法可行。

Lexluth0r avatar Feb 23 '21 03:02 Lexluth0r

欢迎提交PR

jqhph avatar Feb 23 '21 03:02 jqhph