jqh 5 years ago
parent
commit
38848d7bb5
3 changed files with 7 additions and 19 deletions
  1. 0 16
      src/Console/stubs/bootstrap.stub
  2. 2 2
      src/Form/Field/HasMany.php
  3. 5 1
      src/Form/Field/Tags.php

+ 0 - 16
src/Console/stubs/bootstrap.stub

@@ -24,19 +24,3 @@ use Dcat\Admin\Show;
  * Admin::js('/packages/prettydocs/js/main.js');
  *
  */
-
-Grid\Column::resolving(function () {
-
-//    Grid\Column::define('code', function ($v) {
-//        return "<code>$v</code>";
-//    });
-
-}, true);
-
-Show\Field::resolving(function () {
-
-//    Show\Field::define('code', function ($v) {
-//        return "<code>$v</code>";
-//    });
-
-}, true);

+ 2 - 2
src/Form/Field/HasMany.php

@@ -439,8 +439,8 @@ class HasMany extends Field
             }
         } else {
             if (is_array($this->value)) {
-                foreach ($this->value as $data) {
-                    $key = Arr::get($data, $this->getKeyName());
+                foreach ($this->value as $idx => $data) {
+                    $key = Arr::get($data, $this->getKeyName(), $idx);
 
                     $forms[$key] = $this->buildNestedForm($this->column, $this->builder, $key)
                         ->fill($data);

+ 5 - 1
src/Form/Field/Tags.php

@@ -123,9 +123,13 @@ class Tags extends Field
      */
     protected function prepareToSave($value)
     {
+        if (! is_array($value)) {
+            return $value;
+        }
+
         $value = array_filter($value, 'strlen');
 
-        if (is_array($value) && ! Arr::isAssoc($value)) {
+        if ($value && ! Arr::isAssoc($value)) {
             $value = implode(',', $value);
         }