Merge branch 'master' of https://git.mcnd.ca/mcndave/picea-ui
This commit is contained in:
commit
6020fa300d
8 files changed
+73
-42
No files matched your search
+4
-15
@@ -38,26 +38,23 @@ class UiSelect extends UiElement implements Extension {
|
||||
protected function setList(array $list, $selected, bool $strict = true) : void
|
||||
{
|
||||
foreach($list as $key => $item) {
|
||||
$isSelected = $this->isSelected($key, $selected, $strict);
|
||||
|
||||
if ($item instanceof UiElement) {
|
||||
|
||||
$this->append($item);
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif ( is_array($item) ) {
|
||||
$obj = new UiElement("optgroup");
|
||||
$obj->text($key);
|
||||
$obj->attributes(['label' => $key]);
|
||||
|
||||
foreach($item as $subKey => $subItem) {
|
||||
$obj->append($this->createOption((string) $subItem, $subKey, $isSelected));
|
||||
$obj->append($this->createOption((string) $subItem, $subKey, $this->isSelected($subKey, $selected, $strict)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$obj = $this->createOption((string) $item, $key, $isSelected);
|
||||
$obj = $this->createOption((string) $item, $key, $this->isSelected($key, $selected, $strict));
|
||||
}
|
||||
|
||||
|
||||
$this->append($obj);
|
||||
}
|
||||
}
|
||||
@@ -77,14 +74,6 @@ class UiSelect extends UiElement implements Extension {
|
||||
|
||||
protected function isSelected($check, $value, bool $strict = true) : bool
|
||||
{
|
||||
|
||||
if (false !== ( $f = filter_var($value, FILTER_VALIDATE_INT) ) ) {
|
||||
$value = $f;
|
||||
}
|
||||
elseif (false !== ( $f = filter_var($value, FILTER_VALIDATE_FLOAT) ) ) {
|
||||
$value = $f;
|
||||
}
|
||||
|
||||
return $strict ? $check === $value : $check == $value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user