From be637551be6e643275d056114516d083d997ce4e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 9 Mar 2016 20:55:26 +0100 Subject: [PATCH] application/forms: unify and clean up group forms --- application/forms/IcingaHostGroupForm.php | 8 +++----- application/forms/IcingaServiceGroupForm.php | 9 ++++----- application/forms/IcingaUserGroupForm.php | 9 +++------ library/Director/Web/Form/DirectorObjectForm.php | 12 ++++++++++++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/application/forms/IcingaHostGroupForm.php b/application/forms/IcingaHostGroupForm.php index 69eb467c..8b404e1a 100644 --- a/application/forms/IcingaHostGroupForm.php +++ b/application/forms/IcingaHostGroupForm.php @@ -13,12 +13,10 @@ class IcingaHostGroupForm extends DirectorObjectForm $this->addElement('text', 'object_name', array( 'label' => $this->translate('Hostgroup'), 'required' => true, - 'description' => $this->translate('Icinga object name for this hostgroup') + 'description' => $this->translate('Icinga object name for this host group') )); - $this->addElement('text', 'display_name', array( - 'label' => $this->translate('Display Name'), - 'description' => $this->translate('The name which should displayed.') - )); + $this->addGroupDisplayNameElement() + ->setButtons(); } } diff --git a/application/forms/IcingaServiceGroupForm.php b/application/forms/IcingaServiceGroupForm.php index 045caf1e..9b13fb64 100644 --- a/application/forms/IcingaServiceGroupForm.php +++ b/application/forms/IcingaServiceGroupForm.php @@ -9,15 +9,14 @@ class IcingaServiceGroupForm extends DirectorObjectForm public function setup() { $this->addHidden('object_type', 'object'); + $this->addElement('text', 'object_name', array( 'label' => $this->translate('Servicegroup'), 'required' => true, - 'description' => $this->translate('Icinga object name for this servicegroup') + 'description' => $this->translate('Icinga object name for this service group') )); - $this->addElement('text', 'display_name', array( - 'label' => $this->translate('Display Name'), - 'description' => $this->translate('The name which should displayed.') - )); + $this->addGroupDisplayNameElement() + ->setButtons(); } } diff --git a/application/forms/IcingaUserGroupForm.php b/application/forms/IcingaUserGroupForm.php index bb0b0860..ff568a87 100644 --- a/application/forms/IcingaUserGroupForm.php +++ b/application/forms/IcingaUserGroupForm.php @@ -13,14 +13,11 @@ class IcingaUserGroupForm extends DirectorObjectForm $this->addElement('text', 'object_name', array( 'label' => $this->translate('Usergroup'), 'required' => true, - 'description' => $this->translate('Icinga object name for this usergroup') + 'description' => $this->translate('Icinga object name for this user group') )); - $this->addElement('text', 'display_name', array( - 'label' => $this->translate('Display Name'), - 'description' => $this->translate('The name which should displayed.') - )); + $this->addGroupDisplayNameElement() + ->setButtons(); - $this->setButtons(); } } diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 362342a5..98b67aea 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -981,6 +981,18 @@ print_r($object); return $this; } + protected function addGroupDisplayNameElement() + { + $this->addElement('text', 'display_name', array( + 'label' => $this->translate('Display Name'), + 'description' => $this->translate( + 'An alternative display name for this group. If you wonder how this' + . ' could be helpful just leave it blank') + )); + + return $this; + } + protected function addCheckCommandElements() { $this->addElement('select', 'check_command_id', array(