From 60ac506c68ef01af6489f34b9ea1be0f19ff353d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 23 Jun 2023 16:41:27 +0200 Subject: [PATCH] wait #6069 @0.25 --- src/app/Magic/Fields/SelectFromArray.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index c2e55a2..763a9a2 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -24,11 +24,22 @@ class SelectFromArray extends Field protected $_ajax = true; protected $_allowsHTML = false; + protected $_excludedOptions = []; + protected $_showSeletedOption = false; public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['options' => $this->getOptions(), 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple, 'ajax' => $this->_ajax, 'allows_html' => $this->_allowsHTML, 'show_selected_option' => $this->_showSeletedOption]); + return array_merge(parent::getDefaultAttributes(), [ + 'options' => $this->getOptionsFiltered(), + 'excluded_options' => $this->_excludedOptions, + 'options_aliases' => $this->_options_aliases, + 'allows_null' => $this->_allowNull, + 'allows_multiple' => $this->_multiple, + 'ajax' => $this->_ajax, + 'allows_html' => $this->_allowsHTML, + 'show_selected_option' => $this->_showSeletedOption + ]); } protected function _postSetAttributes() @@ -68,6 +79,17 @@ class SelectFromArray extends Field return $this->_options; } + public function getOptionsFiltered() + { + $res = $this->getOptions(); + foreach ($this->_excludedOptions as $excludedOption) { + if (isset($res[$excludedOption])) { + unset($res[$excludedOption]); + } + } + return $res; + } + public function getColumnData() { $res = parent::getColumnData(); -- 2.39.5