Commit f747356e372bdb4da274da2d805bbc74cc5a24fc
1 parent
829e95d9
Allow dev's to create a "no selection" option.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5938 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
21 additions
and
0 deletions
plugins/ktcore/KTWidgets.php
| ... | ... | @@ -170,6 +170,27 @@ class KTCoreSelectionWidget extends KTWidget { |
| 170 | 170 | $oTemplating =& KTTemplating::getSingleton(); |
| 171 | 171 | $oTemplate = $oTemplating->loadTemplate($this->sTemplate); |
| 172 | 172 | |
| 173 | + // have to do this here, and not in "configure" since it breaks | |
| 174 | + // entity-select. | |
| 175 | + $unselected = KTUtil::arrayGet($this->aOptions, 'unselected_label'); | |
| 176 | + if (!empty($unselected)) { | |
| 177 | + // NBM: we get really, really nasty interactions if we try merge | |
| 178 | + // NBM: items with numeric (but important) key values and other | |
| 179 | + // NBM: numerically / null keyed items | |
| 180 | + $vocab = array(); | |
| 181 | + $vocab[] = $unselected; | |
| 182 | + foreach ($this->aVocab as $k => $v) { | |
| 183 | + $vocab[$k] = $v; | |
| 184 | + } | |
| 185 | + | |
| 186 | + $this->aVocab = $vocab; | |
| 187 | + | |
| 188 | + // make sure its the selected one if there's no value specified. | |
| 189 | + if (empty($this->value)) { | |
| 190 | + $this->value = 0; | |
| 191 | + } | |
| 192 | + } | |
| 193 | + | |
| 173 | 194 | // performance optimisation for large selected sets. |
| 174 | 195 | if ($this->bMulti) { |
| 175 | 196 | $this->_valuesearch = array(); | ... | ... |