Ver Fonte

增加 Form\Tree::treeState() 方法控制是否禁止选中父级节点

jqh há 4 anos atrás
pai
commit
5a499ea696
1 ficheiros alterados com 15 adições e 0 exclusões
  1. 15 0
      src/Form/Field/Tree.php

+ 15 - 0
src/Form/Field/Tree.php

@@ -21,6 +21,7 @@ class Tree extends Field
         ],
         'checkbox' => [
             'keep_selected_style' => false,
+            'three_state' => true,
         ],
         'types' => [
             'default'  => [
@@ -69,6 +70,20 @@ class Tree extends Field
         return $this;
     }
 
+    /**
+     * 设置父级复选框是否禁止被单独选中.
+     *
+     * @param bool $value
+     *
+     * @return $this
+     */
+    public function treeState(bool $value = true)
+    {
+        $this->options['checkbox']['three_state'] = $value;
+
+        return $this;
+    }
+
     /**
      * 过滤父节点.
      *