corrections sur les controles

This commit is contained in:
Jephté Clain 2025-04-22 18:54:21 +04:00
parent 84bad2be0c
commit 3933fd1e72

View File

@ -599,16 +599,16 @@ class Form extends ComponentPrintable implements IParametrable, ArrayAccess, Cou
/** @var ?array */ /** @var ?array */
protected $hiddenControls; protected $hiddenControls;
function addHiddenControl($control, ?string $name=null): self { function addHiddenControl($control, ?string $id=null): self {
A::set($this->hiddenControls, $name, $control); A::set($this->hiddenControls, $id, $control);
return $this; return $this;
} }
/** @var ?array */ /** @var ?array */
protected $controls; protected $controls;
function addControl($control, ?string $name=null): self { function addControl($control, ?string $id=null): self {
A::set($this->controls, $name, $control); A::set($this->controls, $id, $control);
return $this; return $this;
} }
@ -660,7 +660,8 @@ class Form extends ComponentPrintable implements IParametrable, ArrayAccess, Cou
$param["value"] = $value; $param["value"] = $value;
#XXX en attendant le formattage ci-dessus, forcer la format texte pour que #XXX en attendant le formattage ci-dessus, forcer la format texte pour que
# la comparaison puisse se faire # la comparaison puisse se faire
$param["checked"] = strval($currentValue) === strval($value); #XXX si $name est un tableau e.g values[] le test ci-dessous ne fonctionne pas
$param["checked"] ??= strval($currentValue) === strval($value);
break; break;
case self::NV: case self::NV:
if ($value === null) $value = $this->get($key, $default); if ($value === null) $value = $this->get($key, $default);
@ -672,7 +673,7 @@ class Form extends ComponentPrintable implements IParametrable, ArrayAccess, Cou
if ($params === null) $params = $param; if ($params === null) $params = $param;
else A::update_n($params, $param); else A::update_n($params, $param);
return [new $controlClass($this, $params), $name]; return [new $controlClass($this, $params), $key];
} }
private function _prepareControls(): ?array { private function _prepareControls(): ?array {