Sfoglia il codice sorgente

修复部分表单字段不支持单个页面同时渲染多个的问题

jqh 4 anni fa
parent
commit
0390ab07c3

+ 2 - 2
resources/views/form/editor.blade.php

@@ -6,14 +6,14 @@
 
         @include('admin::form.error')
 
-        <textarea class="form-control {{$class}} form-field-editor" name="{{$name}}" placeholder="{{ $placeholder }}" {!! $attributes !!} >{{ $value }}</textarea>
+        <textarea class="form-control {{$class}}" name="{{$name}}" placeholder="{{ $placeholder }}" {!! $attributes !!} >{{ $value }}</textarea>
 
         @include('admin::form.help-block')
 
     </div>
 </div>
 
-<script require="@tinymce" init=".form-field-editor" id>
+<script require="@tinymce" init="{!! $selector !!}">
     var opts = {!! admin_javascript_json($options) !!};
 
     opts.selector = '#'+id;

+ 2 - 2
resources/views/form/file.blade.php

@@ -13,7 +13,7 @@
     }
 </style>
 
-<div class="{{$viewClass['form-group']}} form-field-file">
+<div class="{{$viewClass['form-group']}} {{ $class }}">
 
     <label for="{{$column}}" class="{{$viewClass['label']}} control-label">{!! $label !!}</label>
 
@@ -49,7 +49,7 @@
     </div>
 </div>
 
-<script require="@webuploader" init=".form-field-file">
+<script require="@webuploader" init="{!! $selector !!}">
     var uploader,
         newPage,
         options = {!! $options !!};

+ 2 - 2
resources/views/form/markdown.blade.php

@@ -10,7 +10,7 @@
 
         @include('admin::form.error')
 
-        <div class="{{$class}} form-field-markdown" {!! $attributes !!}>
+        <div class="{{$class}}" {!! $attributes !!}>
             <textarea class="d-none" name="{{$name}}" placeholder="{{ $placeholder }}">{!! $value !!}</textarea>
         </div>
 
@@ -19,6 +19,6 @@
     </div>
 </div>
 
-<script require="@markdown" init=".form-field-markdown">
+<script require="@markdown" init="{!! $selector !!}">
     editormd(id, {!! $options !!});
 </script>

+ 2 - 2
resources/views/form/tree.blade.php

@@ -2,7 +2,7 @@
 
     <label class="{{$viewClass['label']}} control-label">{!! $label !!}</label>
 
-    <div class="{{$viewClass['field']}} form-field-tree">
+    <div class="{{$viewClass['field']}} {{ $class }}">
 
         @include('admin::form.error')
 
@@ -22,7 +22,7 @@
     </div>
 </div>
 
-<script require="@jstree" init=".form-field-tree">
+<script require="@jstree" init="{!! $selector !!}">
     var $tree = $this.find('.jstree-wrapper .da-tree'),
         $input = $this.find('.hidden-input'),
         opts = {!! admin_javascript_json($options) !!},

+ 13 - 0
src/Form/Field.php

@@ -1187,6 +1187,15 @@ class Field implements Renderable
         return $this;
     }
 
+    protected function defaultAttribute($attribute, $value)
+    {
+        if (! array_key_exists($attribute, $this->attributes)) {
+            $this->attribute($attribute, $value);
+        }
+
+        return $this;
+    }
+
     /**
      * If this field should render.
      *
@@ -1235,6 +1244,10 @@ class Field implements Renderable
             return '';
         }
 
+        if (is_string($class = $this->getElementClassString())) {
+            $this->defaultAttribute('class', $class);
+        }
+
         $this->callComposing();
 
         $this->withScript();

+ 0 - 9
src/Form/Field/PlainInput.php

@@ -28,13 +28,4 @@ trait PlainInput
             $this->view = 'admin::form.input';
         }
     }
-
-    protected function defaultAttribute($attribute, $value)
-    {
-        if (! array_key_exists($attribute, $this->attributes)) {
-            $this->attribute($attribute, $value);
-        }
-
-        return $this;
-    }
 }