diff --git a/application/forms/Config/UserGroup/DbUserGroupBackendForm.php b/application/forms/Config/UserGroup/DbUserGroupBackendForm.php index 9f1915968..9d7545fe7 100644 --- a/application/forms/Config/UserGroup/DbUserGroupBackendForm.php +++ b/application/forms/Config/UserGroup/DbUserGroupBackendForm.php @@ -26,6 +26,32 @@ class DbUserGroupBackendForm extends Form */ public function createElements(array $formData) { + $this->addElement( + 'text', + 'name', + array( + 'required' => true, + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( + 'The name of this user group backend that is used to differentiate it from others' + ), + 'validators' => array( + array( + 'Regex', + false, + array( + 'pattern' => '/^[^\\[\\]:]+$/', + 'messages' => array( + 'regexNotMatch' => $this->translate( + 'The name cannot contain \'[\', \']\' or \':\'.' + ) + ) + ) + ) + ) + ) + ); + $resourceNames = $this->getDatabaseResourceNames(); $this->addElement( 'select', @@ -37,6 +63,15 @@ class DbUserGroupBackendForm extends Form 'multiOptions' => empty($resourceNames) ? array() : array_combine($resourceNames, $resourceNames) ) ); + + $this->addElement( + 'hidden', + 'backend', + array( + 'disabled' => true, // Prevents the element from being submitted, see #7717 + 'value' => 'db' + ) + ); } /** diff --git a/application/forms/Config/UserGroup/LdapUserGroupBackendForm.php b/application/forms/Config/UserGroup/LdapUserGroupBackendForm.php index 68b4de702..a426393c6 100644 --- a/application/forms/Config/UserGroup/LdapUserGroupBackendForm.php +++ b/application/forms/Config/UserGroup/LdapUserGroupBackendForm.php @@ -31,6 +31,32 @@ class LdapUserGroupBackendForm extends Form */ public function createElements(array $formData) { + $this->addElement( + 'text', + 'name', + array( + 'required' => true, + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( + 'The name of this user group backend that is used to differentiate it from others' + ), + 'validators' => array( + array( + 'Regex', + false, + array( + 'pattern' => '/^[^\\[\\]:]+$/', + 'messages' => array( + 'regexNotMatch' => $this->translate( + 'The name cannot contain \'[\', \']\' or \':\'.' + ) + ) + ) + ) + ) + ) + ); + $resourceNames = $this->getLdapResourceNames(); $this->addElement( 'select', @@ -89,6 +115,15 @@ class LdapUserGroupBackendForm extends Form $this->createGroupConfigElements($defaults, $groupConfigDisabled); $this->createUserConfigElements($defaults, $userConfigDisabled, $dnDisabled); + + $this->addElement( + 'hidden', + 'backend', + array( + 'disabled' => true, // Prevents the element from being submitted, see #7717 + 'value' => $formData['type'] + ) + ); } /** diff --git a/application/forms/Config/UserGroup/UserGroupBackendForm.php b/application/forms/Config/UserGroup/UserGroupBackendForm.php index d47e1f4fa..7f57408c7 100644 --- a/application/forms/Config/UserGroup/UserGroupBackendForm.php +++ b/application/forms/Config/UserGroup/UserGroupBackendForm.php @@ -158,32 +158,6 @@ class UserGroupBackendForm extends ConfigForm */ public function createElements(array $formData) { - $this->addElement( - 'text', - 'name', - array( - 'required' => true, - 'label' => $this->translate('Backend Name'), - 'description' => $this->translate( - 'The name of this user group backend that is used to differentiate it from others' - ), - 'validators' => array( - array( - 'Regex', - false, - array( - 'pattern' => '/^[^\\[\\]:]+$/', - 'messages' => array( - 'regexNotMatch' => $this->translate( - 'The name cannot contain \'[\', \']\' or \':\'.' - ) - ) - ) - ) - ) - ) - ); - // TODO(jom): We did not think about how to configure custom group backends yet! $backendTypes = array( 'db' => $this->translate('Database'), @@ -196,15 +170,6 @@ class UserGroupBackendForm extends ConfigForm $backendType = key($backendTypes); } - $this->addElement( - 'hidden', - 'backend', - array( - 'disabled' => true, // Prevents the element from being submitted, see #7717 - 'value' => $backendType - ) - ); - $this->addElement( 'select', 'type', diff --git a/modules/setup/application/forms/UserGroupBackendPage.php b/modules/setup/application/forms/UserGroupBackendPage.php index 6c986bf0a..fbc2d44f0 100644 --- a/modules/setup/application/forms/UserGroupBackendPage.php +++ b/modules/setup/application/forms/UserGroupBackendPage.php @@ -110,6 +110,7 @@ class UserGroupBackendPage extends Form $backendForm->create($formData); $userBackendOptions = $backendForm->getElement('user_backend')->getMultiOptions(); unset($userBackendOptions['none']); + $backendForm->getElement('name')->setValue('icingaweb2'); $backendForm->getElement('user_backend')->setMultiOptions($userBackendOptions); $this->addSubForm($backendForm, 'backend_form'); }