CloneObject: use modern loading

This commit is contained in:
Thomas Gelf 2017-07-25 10:16:15 +02:00
parent 649fff7486
commit b675d37b6f
2 changed files with 11 additions and 8 deletions

View File

@ -3,19 +3,20 @@
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Web\Form\QuickForm;
use Icinga\Module\Director\Web\Form\DirectorForm;
class IcingaCloneObjectForm extends QuickForm
class IcingaCloneObjectForm extends DirectorForm
{
/** @var IcingaObject */
protected $object;
public function setup()
{
$name = $this->object->getObjectName();
$this->addElement('text', 'new_object_name', array(
'label' => $this->translate('New name'),
'required' => true,
'value' => $this->object->getObjectName(),
'value' => $name,
));
$this->addElement('select', 'clone_type', array(
@ -29,7 +30,7 @@ class IcingaCloneObjectForm extends QuickForm
$this->submitLabel = sprintf(
$this->translate('Clone "%s"'),
$this->object->getObjectName()
$name
);
}

View File

@ -10,6 +10,7 @@ use Icinga\Module\Director\Deployment\DeploymentInfo;
use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\Exception\NestingError;
use Icinga\Module\Director\Forms\DeploymentLinkForm;
use Icinga\Module\Director\Forms\IcingaCloneObjectForm;
use Icinga\Module\Director\Forms\IcingaObjectFieldForm;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Objects\IcingaObjectGroup;
@ -234,14 +235,15 @@ abstract class ObjectController extends ActionController
$this->assertPermission('director/' . $ltype);
$this->tabs()->activate('modify');
$this->addTitle($this->translate('Clone Icinga %s'), ucfirst($type));
$form = $this->loadForm('icingaCloneObject')->setObject($this->object);
$form->handleRequest();
$form = IcingaCloneObjectForm::load()
->setObject($this->object)
->handleRequest();
$this->content()->add($form);
$this->actions()->add(Link::create(
$this->translate('back'),
'director/' . $ltype,
array('name' => $this->object->object_name),
array('class' => 'icon-left-big')
['name' => $this->object->getObjectName()],
['class' => 'icon-left-big']
));
}