aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/forms/Part.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/classes/forms/Part.php')
-rw-r--r--lib/classes/forms/Part.php36
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
*/