IcingaObjectFieldForm: add delete button
This commit is contained in:
parent
45e6cb9944
commit
1ec6f86e8e
application/forms
|
@ -60,8 +60,28 @@ class IcingaObjectFieldForm extends DirectorObjectForm
|
|||
)
|
||||
));
|
||||
|
||||
$this->setSubmitLabel(
|
||||
$this->translate('Add new field')
|
||||
);
|
||||
if ($this->object === null) {
|
||||
$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…
Reference in New Issue