jqh 4 years ago
parent
commit
a6afac8b5c
3 changed files with 17 additions and 15 deletions
  1. 1 1
      src/Admin.php
  2. 0 6
      src/Form/Layout.php
  3. 16 8
      src/Widgets/Form.php

+ 1 - 1
src/Admin.php

@@ -36,7 +36,7 @@ class Admin
      *
      * @var string
      */
-    const VERSION = '1.7.1';
+    const VERSION = '1.7.3';
 
     /**
      * @var array

+ 0 - 6
src/Form/Layout.php

@@ -117,12 +117,6 @@ class Layout
             $html .= $column->render();
         }
 
-        $this->form->fields()->each(function ($field) use (&$html) {
-            if ($field instanceof Form\Field\Hidden) {
-                $html .= $field->render();
-            }
-        });
-
         return $html.'</div>';
     }
 }

+ 16 - 8
src/Widgets/Form.php

@@ -168,6 +168,8 @@ class Form implements Renderable
      */
     protected $confirm = [];
 
+    protected $hasColumns = false;
+
     /**
      * Form constructor.
      *
@@ -392,6 +394,8 @@ class Form implements Renderable
             $callback($this);
         });
 
+        $this->hasColumns = true;
+
         return $this;
     }
 
@@ -808,14 +812,18 @@ JS
     protected function prepareHandler()
     {
         if (method_exists($this, 'handle')) {
-            $this->method('POST');
-            $this->action(route(admin_api_route('form')));
-            $this->hidden(static::REQUEST_NAME)->default(get_called_class());
-            $this->hidden(static::CURRENT_URL_NAME)->default($this->getCurrentUrl());
-
-            if (! empty($this->payload) && is_array($this->payload)) {
-                $this->hidden(static::LAZY_PAYLOAD_NAME)->default(json_encode($this->payload));
-            }
+            $addHiddenFields = function () {
+                $this->method('POST');
+                $this->action(route(admin_api_route('form')));
+                $this->hidden(static::REQUEST_NAME)->default(get_called_class());
+                $this->hidden(static::CURRENT_URL_NAME)->default($this->getCurrentUrl());
+
+                if (! empty($this->payload) && is_array($this->payload)) {
+                    $this->hidden(static::LAZY_PAYLOAD_NAME)->default(json_encode($this->payload));
+                }
+            };
+
+            $this->hasColumns ? $this->column(1, $addHiddenFields) : $addHiddenFields();
         }
     }