autohide_label par control

This commit is contained in:
Jephté Clain 2024-04-23 17:41:15 +04:00
parent 3051fa641c
commit 52631cc977
1 changed files with 8 additions and 2 deletions

View File

@ -13,6 +13,7 @@ abstract class ControlVisualInput extends ControlVisual {
const PARAMETRABLE_PARAMS_SCHEMA = [ const PARAMETRABLE_PARAMS_SCHEMA = [
"label" => ["?content", null, "libellé du champ"], "label" => ["?content", null, "libellé du champ"],
"autohide_label" => ["?bool", null, "faut-il cacher le label s'il y a le placeholder?"],
"placeholder" => ["?content", null, "valeur suggérée"], "placeholder" => ["?content", null, "valeur suggérée"],
"required" => ["?bool", null, "ce champ est-il requis?"], "required" => ["?bool", null, "ce champ est-il requis?"],
"show_required" => ["?bool", null, "faut-il afficher la marque de champ requis?"], "show_required" => ["?bool", null, "faut-il afficher la marque de champ requis?"],
@ -27,6 +28,9 @@ abstract class ControlVisualInput extends ControlVisual {
/** @var array|string */ /** @var array|string */
protected $ppLabel; protected $ppLabel;
/** @var ?bool */
protected $ppAutohideLabel;
/** @var array|string */ /** @var array|string */
protected $ppPlaceholder; protected $ppPlaceholder;
@ -62,8 +66,10 @@ abstract class ControlVisualInput extends ControlVisual {
$name = $this->ppName; $name = $this->ppName;
$value = $this->ppValue; $value = $this->ppValue;
$label = $this->ppLabel; $label = $this->ppLabel;
if ($form->isAutohideLabel() && $this->ppPlaceholder && !$value) $label = null; $autohideLabel = $this->ppAutohideLabel;
$showLabel = $label || !$form->isAutohideLabel(); if ($autohideLabel === null) $autohideLabel = $form->isAutohideLabel();
if ($autohideLabel && $this->ppPlaceholder && !$value) $label = null;
$showLabel = $label || !$autohideLabel;
if ($label && $this->ppRequired && $this->ppShowRequired) { if ($label && $this->ppRequired && $this->ppShowRequired) {
$label = [q($label), " <sup class=\"required\" title=\"required\">(*)</sup>"]; $label = [q($label), " <sup class=\"required\" title=\"required\">(*)</sup>"];
} else { } else {