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
1 changed files with 14 additions and 9 deletions

View File

@ -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));
}
}