diff --git a/components/ILIAS/UI/src/Component/Input/Container/Form/Standard.php b/components/ILIAS/UI/src/Component/Input/Container/Form/Standard.php index 9bcb697a9239..d9b7c5b5873c 100755 --- a/components/ILIAS/UI/src/Component/Input/Container/Form/Standard.php +++ b/components/ILIAS/UI/src/Component/Input/Container/Form/Standard.php @@ -36,4 +36,14 @@ public function withSubmitLabel(string $label): Standard; * Gets the submit label of the form. */ public function getSubmitLabel(): ?string; + + /** + * Sets whether the additional button on the top of the form should be rendered + */ + public function withForcedTopButton(bool $forced_top_button): Standard; + + /** + * Gets whether the additional button on the top of the form should be rendered + */ + public function isForcedTopButton(): bool; } diff --git a/components/ILIAS/UI/src/Implementation/Component/Dropzone/File/File.php b/components/ILIAS/UI/src/Implementation/Component/Dropzone/File/File.php index 452f0e916a20..1745debd3575 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Dropzone/File/File.php +++ b/components/ILIAS/UI/src/Implementation/Component/Dropzone/File/File.php @@ -281,4 +281,16 @@ public function getPromptTitle(): string { return $this->type; } + + public function withForcedTopButton(bool $forced_top_button): self + { + $clone = clone $this; + $clone->modal = $clone->modal->withForcedTopButton($forced_top_button); + return $clone; + } + + public function isForcedTopButton(): bool + { + return $this->modal->isForcedTopButton(); + } } diff --git a/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Renderer.php index eb2e9f461fb7..4c36470fc25c 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Renderer.php @@ -55,7 +55,9 @@ protected function renderStandard(Form\Standard $component, RendererInterface $d "" ); - $tpl->setVariable("BUTTONS_TOP", $default_renderer->render($submit_button)); + if ($component->isForcedTopButton()) { + $tpl->setVariable("BUTTONS_TOP", $default_renderer->render($submit_button)); + } $tpl->setVariable("BUTTONS_BOTTOM", $default_renderer->render($submit_button)); $tpl->setVariable("INPUTS", $default_renderer->render($component->getInputGroup())); diff --git a/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Standard.php b/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Standard.php index 890fc4c5f663..65f3969d8d79 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Standard.php +++ b/components/ILIAS/UI/src/Implementation/Component/Input/Container/Form/Standard.php @@ -40,6 +40,7 @@ class Standard extends Form implements C\Input\Container\Form\Standard, IsPrompt protected ?string $submit_caption = null; protected Signal $submit_signal; + protected bool $forced_top_button = false; public function __construct( SignalGeneratorInterface $signal_generator, @@ -85,4 +86,22 @@ public function getSubmitSignal(): Signal { return $this->submit_signal; } + + /** + * @inheritDoc + */ + public function withForcedTopButton(bool $forced_top_button): self + { + $clone = clone $this; + $clone->forced_top_button = $forced_top_button; + return $clone; + } + + /** + * @inheritDoc + */ + public function isForcedTopButton(): bool + { + return $this->forced_top_button; + } } diff --git a/components/ILIAS/UI/src/Implementation/Component/Modal/RoundTrip.php b/components/ILIAS/UI/src/Implementation/Component/Modal/RoundTrip.php index e82a25b4f7ff..e98512b89d02 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Modal/RoundTrip.php +++ b/components/ILIAS/UI/src/Implementation/Component/Modal/RoundTrip.php @@ -234,6 +234,18 @@ public function getSubmitLabel(): ?string return $this->submit_button_label; } + public function withForcedTopButton(bool $forced_top_button): self + { + $clone = clone $this; + $clone->form = $clone->form->withForcedTopButton($forced_top_button); + return $clone; + } + + public function isForcedTopButton(): bool + { + return $this->form->isForcedTopButton(); + } + public function getSubmitSignal(): Signal { return $this->submit_signal; diff --git a/components/ILIAS/UI/tests/Component/Input/Container/Form/StandardFormTest.php b/components/ILIAS/UI/tests/Component/Input/Container/Form/StandardFormTest.php index b125ee42f52f..b98a50a97598 100755 --- a/components/ILIAS/UI/tests/Component/Input/Container/Form/StandardFormTest.php +++ b/components/ILIAS/UI/tests/Component/Input/Container/Form/StandardFormTest.php @@ -126,12 +126,12 @@ public function testRender(): void ]); $r = $this->getDefaultRenderer(); - $html = $this->getDefaultRenderer()->render($form); + $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($form)); $expected = $this->brutallyTrimHTML('
-
+
' . $this->getTextFieldHtml() . '