mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
DirectorObjectForm: provide delete button
This commit is contained in:
parent
e9756b4394
commit
e7687d226a
@ -16,6 +16,8 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
|
|
||||||
protected $className;
|
protected $className;
|
||||||
|
|
||||||
|
protected $deleteButtonName;
|
||||||
|
|
||||||
protected $objectType = 'object';
|
protected $objectType = 'object';
|
||||||
|
|
||||||
protected $fieldsDisplayGroup;
|
protected $fieldsDisplayGroup;
|
||||||
@ -482,8 +484,33 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->handleProperties($object, $values);
|
$this->handleProperties($object, $values);
|
||||||
|
}
|
||||||
|
|
||||||
$this->moveSubmitToBottom();
|
protected function addDeleteButton($label = null)
|
||||||
|
{
|
||||||
|
if ($label === null) {
|
||||||
|
$label = $this->translate('Delete');
|
||||||
|
}
|
||||||
|
|
||||||
|
$el = $this->createElement('submit', $label)->setLabel($label)->setDecorators(array('ViewHelper')); //->removeDecorator('Label');
|
||||||
|
|
||||||
|
$this->deleteButtonName = $el->getName();
|
||||||
|
$this->addElement($el);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasDeleteButton()
|
||||||
|
{
|
||||||
|
return $this->deleteButtonName !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldBeDeleted()
|
||||||
|
{
|
||||||
|
if (! $this->hasDeleteButton()) return false;
|
||||||
|
|
||||||
|
$name = $this->deleteButtonName;
|
||||||
|
return $this->getSentValue($name) === $this->getElement($name)->getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadObject($id)
|
public function loadObject($id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user