diff --git a/sources/Application/UI/Base/Component/Field/Field.php b/sources/Application/UI/Base/Component/Field/Field.php index 3d06f869d..7c1056e49 100644 --- a/sources/Application/UI/Base/Component/Field/Field.php +++ b/sources/Application/UI/Base/Component/Field/Field.php @@ -9,6 +9,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\Field; use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock; use Combodo\iTop\Application\UI\Base\UIBlock; +use utils; /** * @since 3.0.0 @@ -45,6 +46,11 @@ class Field extends UIContentBlock protected $sValueRaw; /** @var string */ protected $sLabel; + /** + * @var string + * @since 3.1.0 + */ + protected $sDescription = ''; /** @var string */ protected $sValueId; @@ -354,4 +360,34 @@ class Field extends UIContentBlock return $this; } + + /** + * @return string + * @since 3.1.0 + */ + public function GetDescription(): string + { + return $this->sDescription; + } + + /** + * @param string $sDescription + * + * @return $this + * @since 3.1.0 + */ + public function SetDescription(string $sDescription) + { + $this->sDescription = $sDescription; + return $this; + } + + /* + * @return bool + * @since 3.1.0 + */ + public function HasDescription(): bool + { + return utils::IsNotNullOrEmptyString($this->GetDescription()); + } } \ 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 2db7c856a..6efba6abd 100644 --- a/sources/Application/UI/Base/Component/Field/FieldUIBlockFactory.php +++ b/sources/Application/UI/Base/Component/Field/FieldUIBlockFactory.php @@ -105,12 +105,14 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory * @api * @param string $sLabel * @param string $sValueHtml + * @param string $sDescription * * @return \Combodo\iTop\Application\UI\Base\Component\Field\Field */ - public static function MakeLarge(string $sLabel, string $sValueHtml = '') + public static function MakeLarge(string $sLabel, string $sValueHtml = '', string $sDescription = '') { $oField = new Field($sLabel, new Html($sValueHtml)); + $oField->SetDescription($sDescription); $oField->SetLayout(Field::ENUM_FIELD_LAYOUT_LARGE); return $oField; } @@ -119,12 +121,14 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory * @api * @param string $sLabel * @param string $sValueHtml + * @param string $sDescription * * @return \Combodo\iTop\Application\UI\Base\Component\Field\Field */ - public static function MakeSmall(string $sLabel, string $sValueHtml = '') + public static function MakeSmall(string $sLabel, string $sValueHtml = '', string $sDescription = '') { $oField = new Field($sLabel, new Html($sValueHtml)); + $oField->SetDescription($sDescription); $oField->SetLayout(Field::ENUM_FIELD_LAYOUT_SMALL); return $oField; } @@ -134,12 +138,14 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory * @param string $sLabel * @param string $sLayout * @param string|null $sId + * @param string $sDescription * * @return \Combodo\iTop\Application\UI\Base\Component\Field\Field */ - 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 $sDescription = '') { $oField = new Field($sLabel, null, $sId); + $oField->SetDescription($sDescription); $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..fb7a858f6 100644 --- a/templates/base/components/field/layout.html.twig +++ b/templates/base/components/field/layout.html.twig @@ -23,6 +23,9 @@ {% endif %} >