CloneSyncRuleForm: do not fail

fixes #1982
This commit is contained in:
Thomas Gelf 2019-10-14 14:24:33 +02:00
parent 2c000d4160
commit d0a29d4716
2 changed files with 5 additions and 2 deletions

View file

@ -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());
}

View file

@ -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()