Browse Source

修复表格选择器无法选中编辑数据问题

jqh 4 years ago
parent
commit
acc51af69c
2 changed files with 26 additions and 12 deletions
  1. 14 0
      src/Form/Field/MultipleSelectTable.php
  2. 12 12
      src/Form/Field/SelectTable.php

+ 14 - 0
src/Form/Field/MultipleSelectTable.php

@@ -2,6 +2,8 @@
 
 namespace Dcat\Admin\Form\Field;
 
+use Dcat\Admin\Support\Helper;
+
 class MultipleSelectTable extends SelectTable
 {
     public static $css = [
@@ -42,4 +44,16 @@ Dcat.grid.SelectTable({
 });
 JS;
     }
+
+    /**
+     * 转化为数组格式保存.
+     *
+     * @param mixed $value
+     *
+     * @return array|mixed
+     */
+    public function prepareInputValue($value)
+    {
+        return Helper::array($value, true);
+    }
 }

+ 12 - 12
src/Form/Field/SelectTable.php

@@ -75,6 +75,18 @@ class SelectTable extends Field
         return $this;
     }
 
+    /**
+     * @param array $options
+     *
+     * @return $this
+     */
+    public function options($options = [])
+    {
+        $this->options = $options;
+
+        return $this;
+    }
+
     /**
      * 设置选中数据显示.
      *
@@ -95,18 +107,6 @@ class SelectTable extends Field
         });
     }
 
-    /**
-     * 转化为数组格式保存.
-     *
-     * @param mixed $value
-     *
-     * @return array|mixed
-     */
-    public function prepareInputValue($value)
-    {
-        return Helper::array($value, true);
-    }
-
     protected function formatOptions()
     {
         $value = Helper::array(old($this->column, $this->value()));