- Fixed UiSelect's selected item method

- Added a new DateTime (WIP from firefox still)
This commit is contained in:
Dave Mc Nicoll committed 2020-01-31 16:37:17 -05:00
1 parent e2c1c7ac39
commit cb2caf895e
5 files changed
+59 -9

No files matched your search

+17 -2
View File
@@ -38,7 +38,10 @@ 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;
@@ -48,11 +51,11 @@ class UiSelect extends UiElement implements Extension {
$obj->text($key);
foreach($item as $subKey => $subItem) {
$obj->append($this->createOption($subItem, $subKey, $strict ? $subKey === $selected : $subKey == $selected));
$obj->append($this->createOption($subItem, $subKey, $isSelected));
}
}
else {
$obj = $this->createOption($item, $key, $strict ? $key === $selected : $key == $selected);
$obj = $this->createOption($item, $key, $isSelected);
}
$this->append($obj);
@@ -71,4 +74,16 @@ class UiSelect extends UiElement implements Extension {
return $option;
}
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;
}
}