jqh vor 4 Jahren
Ursprung
Commit
bf677fd3dc
5 geänderte Dateien mit 15 neuen und 20 gelöschten Zeilen
  1. 1 1
      resources/views/form/hasmany.blade.php
  2. 1 1
      src/Form.php
  3. 3 3
      src/Form/BlockForm.php
  4. 8 14
      src/Form/Builder.php
  5. 2 1
      src/Form/NestedForm.php

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

@@ -1,5 +1,5 @@
 
-<div class="row">
+<div class="row" style="margin-top: 10px;">
     <div class="{{$viewClass['label']}}"><h4 class="pull-right">{!! $label !!}</h4></div>
     <div class="{{$viewClass['field']}}"></div>
 </div>

+ 1 - 1
src/Form.php

@@ -314,7 +314,7 @@ class Form implements Renderable
     {
         $field->setForm($this);
 
-        $this->builder->fields()->push($field);
+        $this->builder->pushField($field);
         $this->builder->layout()->addField($field);
 
         $width = $this->builder->getWidth();

+ 3 - 3
src/Form/BlockForm.php

@@ -96,15 +96,15 @@ class BlockForm extends WidgetForm
 
     public function pushField(Field $field)
     {
-        $this->form->builder()->fields()->push($field);
+        $field->attribute(Field::BUILD_IGNORE, true);
+
+        $this->form->builder()->pushField((clone $field)->display(false));
         $this->fields->push($field);
 
         if ($this->layout()->hasColumns()) {
             $this->layout()->addField($field);
         }
 
-        $field->attribute(Field::BUILD_IGNORE, true);
-
         $field->setForm($this->form);
         $field->setParent($this);
         $field->width($this->width['field'], $this->width['label']);

+ 8 - 14
src/Form/Builder.php

@@ -570,6 +570,13 @@ class Builder
         return $this->elementId ?: ($this->elementId = 'form-'.Str::random(8));
     }
 
+    public function pushField(Field $field)
+    {
+        $this->fields->push($field);
+
+        return $this;
+    }
+
     /**
      * Determine if form fields has files.
      *
@@ -791,20 +798,7 @@ class Builder
             $content = $this->layout->build();
         }
 
-        return <<<EOF
-{$open} {$content} {$this->renderHiddenFields()} {$this->close()}
-EOF;
-    }
-
-    protected function renderHiddenFields()
-    {
-        $html = '';
-
-        foreach ($this->hiddenFields() as $field) {
-            $html .= $field->render();
-        }
-
-        return $html;
+        return "{$open}{$content}{$this->close()}";
     }
 
     /**

+ 2 - 1
src/Form/NestedForm.php

@@ -283,8 +283,9 @@ class NestedForm extends WidgetForm
         }
 
         if (method_exists($this->form, 'builder')) {
-            $this->form->builder()->fields()->push($field);
             $field->attribute(Field::BUILD_IGNORE, true);
+
+            $this->form->builder()->pushField((clone $field)->display(false));
         }
 
         $field->setRelation([