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 = [
"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"],
"required" => ["?bool", null, "ce champ est-il 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 */
protected $ppLabel;
/** @var ?bool */
protected $ppAutohideLabel;
/** @var array|string */
protected $ppPlaceholder;
@ -62,8 +66,10 @@ abstract class ControlVisualInput extends ControlVisual {
$name = $this->ppName;
$value = $this->ppValue;
$label = $this->ppLabel;
if ($form->isAutohideLabel() && $this->ppPlaceholder && !$value) $label = null;
$showLabel = $label || !$form->isAutohideLabel();
$autohideLabel = $this->ppAutohideLabel;
if ($autohideLabel === null) $autohideLabel = $form->isAutohideLabel();
if ($autohideLabel && $this->ppPlaceholder && !$value) $label = null;
$showLabel = $label || !$autohideLabel;
if ($label && $this->ppRequired && $this->ppShowRequired) {
$label = [q($label), " <sup class=\"required\" title=\"required\">(*)</sup>"];
} else {