mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 10:57:40 +02:00
Forms: Introduce RemoveHomeForm
class
This commit is contained in:
parent
4f98b0c696
commit
c382d0fbaa
35
application/forms/Dashboard/RemoveHomeForm.php
Normal file
35
application/forms/Dashboard/RemoveHomeForm.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Forms\Dashboard;
|
||||
|
||||
use Icinga\Web\Notification;
|
||||
use ipl\Html\HtmlElement;
|
||||
|
||||
class RemoveHomeForm extends BaseDashboardForm
|
||||
{
|
||||
public function hasBeenSubmitted()
|
||||
{
|
||||
return $this->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()));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user