Browse Source

数据表格checkbox显示类型兼容非数组值情况

jqh 5 năm trước cách đây
mục cha
commit
a2ddd10c24
2 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 1 1
      src/Admin.php
  2. 3 3
      src/Grid/Displayers/Checkbox.php

+ 1 - 1
src/Admin.php

@@ -35,7 +35,7 @@ class Admin
      *
      * @var string
      */
-    const VERSION = '1.0.0';
+    const VERSION = '1.1.0';
 
     /**
      * @var array

+ 3 - 3
src/Grid/Displayers/Checkbox.php

@@ -3,6 +3,7 @@
 namespace Dcat\Admin\Grid\Displayers;
 
 use Dcat\Admin\Admin;
+use Dcat\Admin\Support\Helper;
 use Illuminate\Contracts\Support\Arrayable;
 
 class Checkbox extends AbstractDisplayer
@@ -20,12 +21,11 @@ class Checkbox extends AbstractDisplayer
             $this->value = explode(',', $this->value);
         }
 
-        if ($this->value instanceof Arrayable) {
-            $this->value = $this->value->toArray();
-        }
+        $this->value = Helper::array($this->value);
 
         foreach ($options as $value => $label) {
             $checked = in_array($value, $this->value) ? 'checked' : '';
+
             $checkboxes .= <<<EOT
 <div class="vs-checkbox-con vs-checkbox-primary" style="margin-bottom: 4px">
     <input type="checkbox" name="grid-checkbox-{$name}[]" value="{$value}" $checked >