]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 24 Jun 2019 16:15:34 +0000 (18:15 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 24 Jun 2019 16:15:34 +0000 (18:15 +0200)
src/app/Magic/Fields/BunchOfFields.php
src/resources/views/fields/bunch.blade.php
src/resources/views/fields/button.blade.php

index 68054b43b1b9098352e1753c1fd2b6c94c39c8df..8c0128bc9d687dcb991bc00ad64faa68b28f0c6e 100644 (file)
@@ -56,7 +56,7 @@ class BunchOfFields extends Field
                 $name .= '-_-' . $item;
             }
             $field->setAttribute('name', $name);
-            $crudfields[] = $field->getDefinition();
+            $crudfields[$name] = $field->getDefinition();
         }
         $this->setAttribute('bunchfields', $crudfields);
     }
index cf4c688a474bf7eba7733a72996ff43838dd3a5a..4bd23aa6b2bf382ad29c370b203af7ce0b16e302 100644 (file)
@@ -1,23 +1,41 @@
 <!-- Bunch -->
 
 <?php
+$empty = [];
+$value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? $empty;
+if ($value == '') {
+    $value = $empty;
+}
+
+if (is_string($value)) {
+    $value = json_decode($value, true);
+}
+
+foreach ($value as $k => $v) {
+    $ik=$field['name'].'___'.$k;
+    if (isset($field['bunchfields'][$ik])) {
+        $field['bunchfields'][$ik]['value'] = $v;
+    }
+}
 
 
 ?>
-<div class="bunch__wrapper col-xs-12">
-    <div @include('crud::inc.field_wrapper_attributes') >
-        <label>{!! $field['label'] !!}</label>
-        @include('crud::inc.field_translatable_icon')
-        <div class="clearfix"></div>
+<div class="bunch__margin col-xs-12">
+    <div class="bunch__wrapper col-xs-12">
+        <div @include('crud::inc.field_wrapper_attributes') >
+            <label>{!! $field['label'] !!}</label>
+            @include('crud::inc.field_translatable_icon')
+            <div class="clearfix"></div>
 
-        @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
+            @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
 
-        <div class="clearfix"></div>
+            <div class="clearfix"></div>
 
-        {{-- HINT --}}
-        @if (isset($field['hint']))
-            <p class="help-block">{!! $field['hint'] !!}</p>
-        @endif
+            {{-- HINT --}}
+            @if (isset($field['hint']))
+                <p class="help-block">{!! $field['hint'] !!}</p>
+            @endif
+        </div>
     </div>
 </div>
 
     {{-- FIELD CSS - will be loaded in the after_styles section --}}
     @push('crud_fields_styles')
         <style type="text/css">
+
+            .bunch__margin {
+                margin: 0;
+            }
+
             .bunch__wrapper {
                 padding: 15px;
                 border: 1px solid #eee;
                 background: #fafafa;
                 margin-bottom: 15px;
             }
-            .bunch__wrapper .form-group{
+
+            .bunch__wrapper .form-group {
                 padding: 0;
             }
 
-            .bunch__wrapper > .form-group > label{
+            .bunch__wrapper > .form-group > label {
                 font-size: 1.2em;
                 margin-bottom: 24px;
             }
index da70cedcf1957c06e16bcee4b35c8b08d48183d1..af2b32314795a921daec9c611b9e422fe70d122a 100644 (file)
@@ -11,6 +11,9 @@ $value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $fie
 if ($value == '') {
     $value = [];
 }
+if (is_string($value)) {
+    $value = json_decode($value,true);
+}
 $value = array_merge($empty, $value);
 
 ?>