浏览代码

修复表单字段disable方法设置false无效问题

jqh 4 年之前
父节点
当前提交
47509ccb54
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/Form/Field.php

+ 12 - 0
src/Form/Field.php

@@ -784,6 +784,12 @@ class Field implements Renderable
      */
     public function readOnly(bool $value = true)
     {
+        if (! $value) {
+            unset($this->attributes['readonly']);
+
+            return $this;
+        }
+
         return $this->attribute('readonly', $value);
     }
 
@@ -796,6 +802,12 @@ class Field implements Renderable
      */
     public function disable(bool $value = true)
     {
+        if (! $value) {
+            unset($this->attributes['disabled']);
+
+            return $this;
+        }
+
         return $this->attribute('disabled', $value);
     }