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

View File

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