modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-08-20 23:07:07 +04:00
parent cb3e55dcc8
commit 81a7f91e65
2 changed files with 10 additions and 4 deletions

View File

@ -643,7 +643,9 @@ class Form extends ComponentPrintable implements IParametrable, ArrayAccess, Cou
$currentValue = $type->format($currentValue);
}
$param["value"] = $value;
$param["checked"] = $currentValue === $value;
#XXX en attendant le formattage ci-dessus, forcer la format texte pour que
# la comparaison puisse se faire
$param["checked"] = strval($currentValue) === strval($value);
break;
case self::NV:
if ($value === null) $value = $this->get($key, $default);

View File

@ -7,11 +7,12 @@ use nur\v\js;
/**
* Class autosubmitSelectPlugin: soumet le formulaire sur l'événement change
*/
class autosubmitOnChangePlugin extends BasePlugin {
class autosubmitOnEventPlugin extends BasePlugin {
const HAVE_JQUERY = true;
function __construct(string $selector, bool $cond=true) {
function __construct(string $selector, string $event="change", bool $cond=true) {
$this->selector = $selector;
$this->event = $event;
$this->cond = $cond;
}
@ -20,13 +21,16 @@ class autosubmitOnChangePlugin extends BasePlugin {
*/
private $selector;
/** @var string événement sur lequel déclencher la soumission du formulaire */
private $event;
/** @var bool ce plugin est-il activé? */
private $cond;
function printJquery(): void {
if (!$this->cond) return;
?>
$(<?=js::qv($this->selector)?>).change(function() {
$(<?=js::qv($this->selector)?>).on(<?=js::qv($this->event)?>, function() {
$(this).closest("form").submit();
return false;
});