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
This commit is contained in:
Johannes Meyer 2014-09-02 14:53:15 +02:00
parent 539ab91ffa
commit 5b14d8fed3

View File

@ -202,7 +202,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) { if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
$backendForm = $this->getBackendForm($this->getElement('type')->getValue()); $backendForm = $this->getBackendForm($this->getElement('type')->getValue());
if (false === $backendForm->isValidAuthenticationBackend($this)) { if (false === $backendForm->isValidAuthenticationBackend($this)) {
$this->addForceCreationCheckbox(); $this->addElement($this->getForceCreationCheckbox());
return false; 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 * 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', 'checkbox',
'force_creation', 'force_creation',
array( array(
@ -297,7 +299,8 @@ class AuthenticationBackendConfigForm extends ConfigForm
$backendTypes['autologin'] = t('Autologin'); $backendTypes['autologin'] = t('Autologin');
} }
$typeSelection = $this->createElement( $elements = array();
$elements[] = $this->createElement(
'select', 'select',
'type', 'type',
array( array(
@ -310,9 +313,11 @@ class AuthenticationBackendConfigForm extends ConfigForm
) )
); );
return array_merge( if (isset($formData['force_creation']) && $formData['force_creation']) {
array($typeSelection), // In case another error occured and the checkbox was displayed before
$this->getBackendForm($backendType)->createElements($formData) $elements[] = $this->getForceCreationCheckbox();
); }
return array_merge($elements, $this->getBackendForm($backendType)->createElements($formData));
} }
} }