- Small bugfixes within value comparison for UiInput and small bugfixe in select repairing broken options.
This commit is contained in:
parent
b4fc4dd37f
commit
69c7121981
|
@ -21,7 +21,7 @@ class UiInput extends UiElement implements Extension {
|
|||
'tag-type' => "single",
|
||||
];
|
||||
|
||||
protected ? string $value;
|
||||
protected /* ? mixed */ $value;
|
||||
|
||||
protected string $name;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class UiInput extends UiElement implements Extension {
|
|||
return "<?php echo ( new \\" . static::class . "() )->buildHtml($arguments) ?>";
|
||||
}
|
||||
|
||||
public function buildHtml(string $name, ? string $value = null, array $attributes = [], array $options = []) : string
|
||||
public function buildHtml(string $name, /*? mixed */ $value = null, array $attributes = [], array $options = []) : string
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
|
@ -42,6 +42,11 @@ class UiInput extends UiElement implements Extension {
|
|||
$this->options += $options;
|
||||
}
|
||||
|
||||
if ($attributes['class'] ?? false) {
|
||||
$attributes['class'] .= " {$this->attributes['class']}";
|
||||
unset($this->attributes['class']);
|
||||
}
|
||||
|
||||
$this->attributes([ 'name' => $name ] + $attributes + $this->attributes + $this->objectAttribute());
|
||||
|
||||
return $this->render();
|
||||
|
|
|
@ -13,7 +13,7 @@ class UiRadio extends UiInput {
|
|||
|
||||
protected function objectAttribute() : array
|
||||
{
|
||||
if ( $this->options['value'] ?? false && ( $this->options['value'] === $this->value ) ) {
|
||||
if ( ( $this->options['value'] ?? false ) && ( $this->options['value'] === $this->value ) ) {
|
||||
return [
|
||||
'checked' => "checked"
|
||||
];
|
||||
|
|
|
@ -38,24 +38,22 @@ 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($subItem, $subKey, $isSelected));
|
||||
$obj->append($this->createOption($subItem, $subKey, $this->isSelected($subKey, $selected, $strict)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$obj = $this->createOption($item, $key, $isSelected);
|
||||
$obj = $this->createOption($item, $key, $this->isSelected($key, $selected, $strict));
|
||||
}
|
||||
|
||||
$this->append($obj);
|
||||
|
|
|
@ -28,6 +28,8 @@ class FormHandler {
|
|||
$this->context = method_exists($form, 'getContext') ? $form->getContext($request) : new FormContext($request);
|
||||
}
|
||||
|
||||
$this->request->context = $this->context;
|
||||
|
||||
$this->formSent();
|
||||
$this->initialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue