mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 07:44:05 +02:00
IcingaObjectFieldForm: add delete button
This commit is contained in:
parent
45e6cb9944
commit
1ec6f86e8e
@ -60,8 +60,28 @@ class IcingaObjectFieldForm extends DirectorObjectForm
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->setSubmitLabel(
|
if ($this->object === null) {
|
||||||
$this->translate('Add new field')
|
$this->setSubmitLabel(
|
||||||
);
|
$this->translate('Add new field')
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->setSubmitLabel(
|
||||||
|
$this->translate('Store')
|
||||||
|
);
|
||||||
|
$this->addElement('submit', 'delete', array(
|
||||||
|
'label' => $this->translate('Delete')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function onRequest()
|
||||||
|
{
|
||||||
|
parent::onRequest();
|
||||||
|
|
||||||
|
if ($this->getSentValue('delete') === $this->translate('Delete')) {
|
||||||
|
$this->object()->delete();
|
||||||
|
$this->setSuccessUrl($this->getSuccessUrl()->without('field_id'));
|
||||||
|
$this->redirectOnSuccess($this->translate('Field has been removed'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user