Bläddra i källkod

修复禁用session时表单页面出错bug

jqh 5 år sedan
förälder
incheckning
78c14aa299
4 ändrade filer med 11 tillägg och 7 borttagningar
  1. 1 1
      resources/views/form/footer.blade.php
  2. 1 1
      src/Form/Builder.php
  3. 9 1
      src/Layout/Content.php
  4. 0 4
      src/Traits/ModelTree.php

+ 1 - 1
resources/views/form/footer.blade.php

@@ -9,7 +9,7 @@
 
         @if(! empty($buttons['submit']))
         <div class="btn-group pull-right">
-            <button type="submit" class="btn btn-primary">{{ trans('admin.submit') }}</button>
+            <button class="btn btn-primary submit">{{ trans('admin.submit') }}</button>
         </div>
 
         @if($checkboxes)

+ 1 - 1
src/Form/Builder.php

@@ -839,7 +839,7 @@ EOF;
 (function () {
     var f = $('#{$this->elementId()}');
 
-    f.find('[type="submit"]').click(function () {
+    f.find('button.submit').click(function () {
         var t = $(this);
     
         LA.Form({

+ 9 - 1
src/Layout/Content.php

@@ -6,6 +6,7 @@ use Closure;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Renderable;
+use Illuminate\Support\ViewErrorBag;
 
 class Content implements Renderable
 {
@@ -351,6 +352,13 @@ CSS
         }
     }
 
+    protected function shareDefaultErrors()
+    {
+        if (! session()->all()) {
+            view()->share(['errors' => new ViewErrorBag()]);
+        }
+    }
+
     /**
      * Render this content.
      *
@@ -359,8 +367,8 @@ CSS
     public function render()
     {
         $this->callComposing();
-
         $this->setupStyles();
+        $this->shareDefaultErrors();
 
         $items = [
             'header'      => $this->title,

+ 0 - 4
src/Traits/ModelTree.php

@@ -362,10 +362,6 @@ trait ModelTree
     {
         parent::boot();
 
-        if (! trait_exists('\Spatie\EloquentSortable\SortableTrait')) {
-            throw new \Exception('To use ModelTree, please install package [spatie/eloquent-sortable] first.');
-        }
-
         static::saving(function (Model $branch) {
             $parentColumn = $branch->getParentColumn();