mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 04:04:13 +02:00
Fix issue in InputfieldSelect.module where optionLabel() method didn't return labels for option values within optgroups
This commit is contained in:
@@ -144,9 +144,21 @@ class InputfieldSelect extends Inputfield implements InputfieldHasSelectableOpti
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function optionLabel($key, $label = null) {
|
public function optionLabel($key, $label = null) {
|
||||||
if(!isset($this->options[$key])) return false;
|
$returnLabel = false;
|
||||||
if($label !== null) $this->options[$key] = $label;
|
if(isset($this->options[$key])) {
|
||||||
return isset($this->options[$key]) ? $this->options[$key] : null;
|
if($label !== null) $this->options[$key] = $label;
|
||||||
|
$returnLabel = $this->options[$key];
|
||||||
|
} else {
|
||||||
|
foreach($this->options as $k => $v) {
|
||||||
|
if(is_array($v) && isset($v[$key])) {
|
||||||
|
// optgroup
|
||||||
|
if($label !== null) $this->options[$k][$key] = $label;
|
||||||
|
$returnLabel = $v[$key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $returnLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user