IcingaMultiEditForm: fix multi-object delete

fixes #677
This commit is contained in:
Thomas Gelf 2017-04-19 10:57:03 +02:00
parent 24b14184be
commit 34a0179103

View File

@ -97,6 +97,16 @@ class IcingaMultiEditForm extends DirectorObjectForm
*/
protected function onRequest()
{
if ($this->hasBeenSent()) {
$this->handlePost();
}
}
protected function handlePost()
{
if ($this->shouldBeDeleted()) {
$this->deleteObjects();
}
}
protected function setSubmittedMultiValue($key, $value)
@ -277,4 +287,23 @@ class IcingaMultiEditForm extends DirectorObjectForm
return $res;
}
protected function deleteObjects()
{
$msg = sprintf(
'%d objects of type "%s" have been removed',
count($this->objects),
$this->translate($this->object->getShortTableName())
);
foreach ($this->objects as $object) {
$object->delete();
}
if ($this->listUrl) {
$this->setSuccessUrl($this->listUrl);
}
$this->redirectOnSuccess($msg);
}
}