From 5b14d8fed3762f8b99951971a273a86f253fc513 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 2 Sep 2014 14:53:15 +0200 Subject: [PATCH] Fix that the force_creation checkbox disappears after another error Once the user enters invalid data after he tried to save a backend without success (because the backend was not successfully validated) the shown checkbox disappeared in this case regardless of whether it was checked or not. refs #5525 --- .../AuthenticationBackendConfigForm.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/application/forms/Config/AuthenticationBackendConfigForm.php b/application/forms/Config/AuthenticationBackendConfigForm.php index 660658404..6b1cacbdc 100644 --- a/application/forms/Config/AuthenticationBackendConfigForm.php +++ b/application/forms/Config/AuthenticationBackendConfigForm.php @@ -202,7 +202,7 @@ class AuthenticationBackendConfigForm extends ConfigForm if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) { $backendForm = $this->getBackendForm($this->getElement('type')->getValue()); if (false === $backendForm->isValidAuthenticationBackend($this)) { - $this->addForceCreationCheckbox(); + $this->addElement($this->getForceCreationCheckbox()); return false; } } @@ -255,12 +255,14 @@ class AuthenticationBackendConfigForm extends ConfigForm } /** - * Add a checkbox to be displayed at the beginning of the form + * Return a checkbox to be displayed at the beginning of the form * which allows the user to skip the connection validation + * + * @return Zend_Form_Element */ - protected function addForceCreationCheckbox() + protected function getForceCreationCheckbox() { - $this->addElement( + return $this->createElement( 'checkbox', 'force_creation', array( @@ -297,7 +299,8 @@ class AuthenticationBackendConfigForm extends ConfigForm $backendTypes['autologin'] = t('Autologin'); } - $typeSelection = $this->createElement( + $elements = array(); + $elements[] = $this->createElement( 'select', 'type', array( @@ -310,9 +313,11 @@ class AuthenticationBackendConfigForm extends ConfigForm ) ); - return array_merge( - array($typeSelection), - $this->getBackendForm($backendType)->createElements($formData) - ); + if (isset($formData['force_creation']) && $formData['force_creation']) { + // In case another error occured and the checkbox was displayed before + $elements[] = $this->getForceCreationCheckbox(); + } + + return array_merge($elements, $this->getBackendForm($backendType)->createElements($formData)); } }