From d0a29d471626fc65171c8fcaa66bc09efc850048 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 14 Oct 2019 14:24:33 +0200 Subject: [PATCH] CloneSyncRuleForm: do not fail fixes #1982 --- application/controllers/SyncruleController.php | 4 ++++ library/Director/Web/Form/CloneSyncRuleForm.php | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/application/controllers/SyncruleController.php b/application/controllers/SyncruleController.php index 7b2ba6c3..4c7d0b8c 100644 --- a/application/controllers/SyncruleController.php +++ b/application/controllers/SyncruleController.php @@ -24,6 +24,7 @@ use Icinga\Module\Director\Web\Table\SyncpropertyTable; use Icinga\Module\Director\Web\Table\SyncRunTable; use Icinga\Module\Director\Web\Tabs\SyncRuleTabs; use Icinga\Module\Director\Web\Widget\SyncRunDetails; +use ipl\Html\Form; use ipl\Html\Html; use gipfl\IcingaWeb2\Link; @@ -509,6 +510,9 @@ class SyncruleController extends ActionController $form = new CloneSyncRuleForm($rule); $this->content()->add($form); + $form->on(Form::ON_SUCCESS, function (CloneSyncRuleForm $form) { + $this->getResponse()->redirectAndExit($form->getSuccessUrl()); + }); $form->handleRequest($this->getServerRequest()); } diff --git a/library/Director/Web/Form/CloneSyncRuleForm.php b/library/Director/Web/Form/CloneSyncRuleForm.php index bb6f1bf9..a3a5a341 100644 --- a/library/Director/Web/Form/CloneSyncRuleForm.php +++ b/library/Director/Web/Form/CloneSyncRuleForm.php @@ -26,7 +26,7 @@ class CloneSyncRuleForm extends Form protected function assemble() { - $this->addElement('rule_name', 'text', [ + $this->addElement('text', 'rule_name', [ 'label' => $this->translate('New name'), 'value' => $this->rule->get('rule_name'), ]); @@ -59,7 +59,6 @@ class CloneSyncRuleForm extends Form } $this->newRule = SyncRule::import($export, $this->getTargetDb()); $this->newRule->store(); - $this->redirectOnSuccess(); } public function getSuccessUrl()