From c382d0fbaa401144beea55361d87106c38b2f51d Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 20 May 2022 16:49:15 +0200 Subject: [PATCH] Forms: Introduce `RemoveHomeForm` class --- .../forms/Dashboard/RemoveHomeForm.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 application/forms/Dashboard/RemoveHomeForm.php diff --git a/application/forms/Dashboard/RemoveHomeForm.php b/application/forms/Dashboard/RemoveHomeForm.php new file mode 100644 index 000000000..6efe91d62 --- /dev/null +++ b/application/forms/Dashboard/RemoveHomeForm.php @@ -0,0 +1,35 @@ +hasBeenSent() && $this->getPopulatedValue('btn_remove'); + } + + protected function assemble() + { + $this->addHtml(HtmlElement::create( + 'h2', + null, + sprintf(t('Please confirm removal of dashboard home "%s"'), $this->dashboard->getActiveHome()->getTitle()) + )); + + $this->addHtml($this->registerSubmitButton('Remove Home')->setName('btn_remove')); + } + + protected function onSuccess() + { + $home = $this->dashboard->getActiveHome(); + $this->dashboard->removeEntry($home); + + Notification::success(sprintf(t('Removed dashboard home "%s" successfully'), $home->getTitle())); + } +}