]> _ Git - cubist_cms-back.git/commitdiff
#2810
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Jun 2019 17:15:00 +0000 (19:15 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 13 Jun 2019 17:15:00 +0000 (19:15 +0200)
src/app/Magic/Fields/Range.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/views/fields/rangeofvalues.blade.php

index f876143be6b2465abfd59e04187a9ef967a3727f..882c9dda834d77962afbe5292ff6615dc1f0c155 100644 (file)
@@ -9,13 +9,14 @@ use Cubist\Backpack\CubistBackpackServiceProvider;
 class Range extends Number
 {
     protected $_adminType = 'rangeofvalues';
+    protected $_cast = 'array';
     protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
 
     public function getDefaultAttributes()
     {
         $res = parent::getDefaultAttributes();
-        $res['first_label'] = trans('cubist_back::first_value');
-        $res['second_label'] = trans('cubist_back::second_value');
+        $res['first_label'] = trans('cubist_back::fields.first_value');
+        $res['second_label'] = trans('cubist_back::fields.second_value');
         return $res;
     }
 }
index 282370c57c561922f22bcabc2d62accdfca76e46..b0cd1ab714cdd0b5b4eff2ea5e00b1ccdac97653 100644 (file)
@@ -82,6 +82,17 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         $this->fill($attributes);
     }
 
+    public function newFromBuilder($attributes = [], $connection = null)
+    {
+        $res = parent::newFromBuilder($attributes, $connection);
+        $this->onRetreived();
+        return $res;
+    }
+
+    public function onRetreived(){
+
+    }
+
     /**
      * Create translated items as json.
      *
index 745adbfd974dcb55c3cbde7e240375ef0f3554a4..673d7295cb8b049a9c7296d60fb09d5d8380d99c 100644 (file)
@@ -5,6 +5,11 @@ $value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $fie
 if ($value == '') {
     $value = $empty;
 }
+
+if (is_string($value)) {
+    $value = json_decode($value, true);
+}
+
 if (!isset($value['first'])) {
     $value['first'] = '';
 }