diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-12-16 13:44:16 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2022-12-16 13:44:16 +0000 |
| commit | d6ec870033743fcc07f8b6c71cb32450cc75abb6 (patch) | |
| tree | 0e900032e4e555f7dbc2770737b9eeed0cdf747d /lib/classes/forms/Part.php | |
| parent | 20ebf68a5481623b362374ba1c0cd7025f2f6dfe (diff) | |
StEP 1596, closes #1596
Closes #1596
Merge request studip/studip!1038
Diffstat (limited to 'lib/classes/forms/Part.php')
| -rw-r--r-- | lib/classes/forms/Part.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/classes/forms/Part.php b/lib/classes/forms/Part.php index 79c573b..4831945 100644 --- a/lib/classes/forms/Part.php +++ b/lib/classes/forms/Part.php @@ -77,6 +77,42 @@ abstract class Part } /** + * Adds a text block inside the form. + * + * @param string $text The text to be added. + * @param bool $text_is_html Whether the text is HTML (true) or plain text (false). Defaults to true. + * @return Text The added text form part. + */ + public function addText(string $text, bool $text_is_html = true): Text + { + $text_part = new Text(); + $text_part->setText($text, $text_is_html); + $text_part->setParent($this); + $this->parts[] = $text_part; + return $text_part; + } + + /** + * Adds a link as a form part. + * + * @param string $title The title of the link. + * @param string $url The URL of the link. + * @param \Icon|null $icon The icon to be used for the link. + * @param array $attributes Additional link attributes. + * + * @return Link The Text form element containing the link as HTML. + */ + public function addLink(string $title, string $url, ?\Icon $icon = null, array $attributes = []): Link + { + $link = new Link($url, $title, $icon); + $link->setAttributes($attributes); + + $this->addPart($link); + + return $link; + } + + /** * Renders this Part object. This could be a section or any other HTML element with child-elements. * @return string */ |
