]> _ Git - cubist_cms-back.git/commitdiff
wip #4031 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 2 Nov 2020 14:20:48 +0000 (15:20 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 2 Nov 2020 14:20:48 +0000 (15:20 +0100)
src/app/Magic/Fields/SelectFromArray.php

index e313bfa968ae5743d1fec3b5387eaa4d8da28a93..c9d00e50d1421e8bd7a778bb7f9085c63baf8daa 100644 (file)
@@ -16,16 +16,28 @@ class SelectFromArray extends Field
     protected $_multiple = false;
     protected $_allowNull = true;
     protected $_options = [];
+    protected $_options_aliases = [];
 
     public function getDefaultAttributes()
     {
-        return array_merge(parent::getDefaultAttributes(), ['options' => $this->_options, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple]);
+        return array_merge(parent::getDefaultAttributes(), ['options' => $this->_options, 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple]);
     }
 
+
     public function getColumnData()
     {
         $res = parent::getColumnData();
         $res['options'] = $this->getAttribute('options');
         return $res;
     }
+
+    public function filterValue($value)
+    {
+        $value = parent::filterValue($value);
+        $aliases = $this->getAttribute('options_aliases', []);
+        if (isset($aliases[$value])) {
+            $value = $aliases[$value];
+        }
+        return $value;
+    }
 }