Explorar o código

修改checkbox问题

liaofei %!s(int64=2) %!d(string=hai) anos
pai
achega
7963309822
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      crmeb/crmeb/services/crud/Service.php

+ 5 - 1
crmeb/crmeb/services/crud/Service.php

@@ -74,10 +74,14 @@ class Service extends Make
                         break;
                     default:
                         $valueContent = "''";
+                        $input = '$info["' . $item['field'] . '"] ?? ';
                         if (in_array($item['type'], ['checkbox'])) {
                             $valueContent = '[]';
+                            $input = '(array)(' . $input . $valueContent . ')';
+                        } else {
+                            $input = $input . $valueContent;
                         }
-                        $from[] = $this->tab(2) . '$rule[] = FormBuilder::' . $item['type'] . '("' . $item['field'] . '", "' . $item['name'] . '", $info["' . $item['field'] . '"] ?? ' . $valueContent . ')' . $this->getOptionContent(in_array($item['type'], ['radio', 'select']), $item['option'] ?? []) . ';';
+                        $from[] = $this->tab(2) . '$rule[] = FormBuilder::' . $item['type'] . '("' . $item['field'] . '", "' . $item['name'] . '",  ' . $input . ')' . $this->getOptionContent(in_array($item['type'], ['radio', 'select', 'checkbox']), $item['option'] ?? []) . ';';
                         break;
                 }
             }