forms: use object_type element

This commit is contained in:
Thomas Gelf 2016-02-17 21:58:28 +01:00
parent 7b1c17799d
commit 8b39a223f8
6 changed files with 27 additions and 34 deletions

View File

@ -8,9 +8,6 @@ class IcingaApiUserForm extends DirectorObjectForm
{
public function setup()
{
// TODO: check behaviour on update!
$objectType = $this->getSentValue('object_type', 'external_object');
$isTemplate = $objectType === 'template';
$this->addHidden('object_type', 'external_object');
$this->addElement('text', 'object_name', array(

View File

@ -8,24 +8,24 @@ class IcingaCommandForm extends DirectorObjectForm
{
public function setup()
{
if ($this->isTemplate()) {
$this->addElement('select', 'methods_execute', array(
'label' => $this->translate('Command type'),
'description' => $this->translate('Whether this should be a template'),
'multiOptions' => array(
null => '- please choose -',
'PluginCheck' => 'Plugin Check Command',
'PluginNotification' => 'Notification Plugin Command',
'PluginEvent' => 'Event Plugin Command',
'IcingaCheck' => 'Icinga Check Command',
'ClusterCheck' => 'Icinga Cluster Command',
'RandomCheck' => 'Random Check Command',
'ClusterZoneCheck' => 'Icinga Cluster Zone Check Command',
'CrlCheck' => 'Crl Check Command',
),
'class' => 'autosubmit'
));
}
$this->addObjectTypeElement();
$this->addElement('select', 'methods_execute', array(
'label' => $this->translate('Command type'),
'multiOptions' => array(
null => '- please choose -',
'PluginCheck' => 'Plugin Check Command',
'PluginNotification' => 'Notification Plugin Command',
'PluginEvent' => 'Event Plugin Command',
'IcingaCheck' => 'Icinga Check Command',
'ClusterCheck' => 'Icinga Cluster Command',
'RandomCheck' => 'Random Check Command',
'ClusterZoneCheck' => 'Icinga Cluster Zone Check Command',
'CrlCheck' => 'Crl Check Command',
),
'required' => ! $this->isTemplate(),
'class' => 'autosubmit'
));
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Command name'),

View File

@ -8,19 +8,9 @@ class IcingaEndpointForm extends DirectorObjectForm
{
public function setup()
{
$isTemplate = $this->getSentValue('object_type') === 'template';
/*
$this->addElement('select', 'object_type', array(
'label' => $this->translate('Object type'),
'description' => $this->translate('Whether this should be a template'),
'multiOptions' => array(
null => '- please choose -',
'object' => 'Endpoint object',
'template' => 'Endpoint template',
)
));
*/
if ($isTemplate) {
$this->addObjectTypeElement();
if ($this->isTemplate()) {
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Endpoint template name'),
'required' => true,

View File

@ -9,6 +9,8 @@ class IcingaHostForm extends DirectorObjectForm
{
public function setup()
{
$this->addObjectTypeElement();
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Hostname'),
'required' => true,
@ -66,6 +68,7 @@ class IcingaHostForm extends DirectorObjectForm
*/
$elements = array(
'object_type',
'object_name',
'display_name',
'address',

View File

@ -8,6 +8,8 @@ class IcingaServiceForm extends DirectorObjectForm
{
public function setup()
{
$this->addObjectTypeElement();
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Name'),
'required' => true,

View File

@ -8,6 +8,7 @@ class IcingaServiceGroupForm extends DirectorObjectForm
{
public function setup()
{
$this->addHidden('object_type', 'object');
$this->addElement('text', 'object_name', array(
'label' => $this->translate('Servicegroup'),
'required' => true,