From: Vincent Vanwaelscappel Date: Mon, 2 Nov 2020 14:20:48 +0000 (+0100) Subject: wip #4031 @0:20 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f96afca6415d885e41046cb4105fb3e2a47a4f1a;p=cubist_cms-back.git wip #4031 @0:20 --- diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index e313bfa..c9d00e5 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -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; + } }