UserGroupBackendForm: Fix that autosubmit do not have any effect

refs #7343
This commit is contained in:
Johannes Meyer 2015-06-05 13:07:16 +02:00
parent cacd97fb46
commit 7ebf185036
1 changed files with 23 additions and 5 deletions

View File

@ -13,6 +13,13 @@ use Icinga\Forms\ConfigForm;
*/
class UserGroupBackendForm extends ConfigForm
{
/**
* The backend to load when displaying the form for the first time
*
* @var string
*/
protected $backendToLoad;
/**
* Initialize this form
*/
@ -53,10 +60,7 @@ class UserGroupBackendForm extends ConfigForm
throw new NotFoundError('No user group backend called "%s" found', $name);
}
$data = $this->config->getSection($name)->toArray();
$data['type'] = $data['backend'];
$data['name'] = $name;
$this->populate($data);
$this->backendToLoad = $name;
return $this;
}
@ -187,7 +191,8 @@ class UserGroupBackendForm extends ConfigForm
'autosubmit' => true,
'label' => $this->translate('Backend Type'),
'description' => $this->translate('The type of this user group backend'),
'multiOptions' => $backendTypes
'multiOptions' => $backendTypes,
'value' => $backendType
)
);
@ -195,4 +200,17 @@ class UserGroupBackendForm extends ConfigForm
$backendForm->createElements($formData);
$this->addElements($backendForm->getElements());
}
/**
* Populate the configuration of the backend to load
*/
public function onRequest()
{
if ($this->backendToLoad) {
$data = $this->config->getSection($this->backendToLoad)->toArray();
$data['type'] = $data['backend'];
$data['name'] = $this->backendToLoad;
$this->populate($data);
}
}
}