diff --git a/sources/application/UI/Base/Component/Field/Field.php b/sources/application/UI/Base/Component/Field/Field.php index 73a1ff653..d76382651 100644 --- a/sources/application/UI/Base/Component/Field/Field.php +++ b/sources/application/UI/Base/Component/Field/Field.php @@ -46,6 +46,8 @@ class Field extends UIContentBlock /** @var string */ protected $sLabel; /** @var string */ + protected $sTooltip = ''; + /** @var string */ protected $sValueId; /** @var string */ @@ -354,4 +356,28 @@ class Field extends UIContentBlock return $this; } + + /** + * @return string + */ + public function GetTooltip(): string + { + return $this->sTooltip; + } + + /** + * @param string $sTooltip + * + * @return $this + */ + public function SetTooltip(string $sTooltip) + { + $this->sTooltip = $sTooltip; + return $this; + } + + public function HasTooltip() : bool + { + return $this->GetTooltip() !== ''; + } } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php index d45703168..052ceb4ae 100644 --- a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php @@ -86,23 +86,26 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory return $oField; } - public static function MakeLarge(string $sLabel, string $sValueHtml = '') + public static function MakeLarge(string $sLabel, string $sValueHtml = '', string $sTooltip = '') { $oField = new Field($sLabel, new Html($sValueHtml)); + $oField->SetTooltip($sTooltip); $oField->SetLayout(Field::ENUM_FIELD_LAYOUT_LARGE); return $oField; } - public static function MakeSmall(string $sLabel, string $sValueHtml = '') + public static function MakeSmall(string $sLabel, string $sValueHtml = '', string $sTooltip = '') { $oField = new Field($sLabel, new Html($sValueHtml)); + $oField->SetTooltip($sTooltip); $oField->SetLayout(Field::ENUM_FIELD_LAYOUT_SMALL); return $oField; } - public static function MakeStandard(string $sLabel = '', string $sLayout = Field::ENUM_FIELD_LAYOUT_SMALL, ?string $sId = null) + public static function MakeStandard(string $sLabel = '', string $sLayout = Field::ENUM_FIELD_LAYOUT_SMALL, ?string $sId = null, string $sTooltip = '') { $oField = new Field($sLabel, null, $sId); + $oField->SetTooltip($sTooltip); $oField->SetLayout($sLayout); return $oField; diff --git a/templates/base/components/field/layout.html.twig b/templates/base/components/field/layout.html.twig index 0b09b8488..4f582bfeb 100644 --- a/templates/base/components/field/layout.html.twig +++ b/templates/base/components/field/layout.html.twig @@ -23,6 +23,9 @@ {% endif %} >
{{ oUIBlock.GetLabel()|raw }} + {% if oUIBlock.HasTooltip() %} + + {% endif %} {% if oUIBlock.GetLayout() == constant("Combodo\\iTop\\Application\\UI\\Base\\Component\\Field\\Field::ENUM_FIELD_LAYOUT_LARGE") %} {% if oUIBlock.GetComments() %}
{{ oUIBlock.GetComments()|raw }}