diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index d73a82dcd..2ce1f5015 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -23,6 +23,13 @@ class AuthBackendPage extends Form */ protected $config; + /** + * Default values for the subform's elements suggested by a previous step + * + * @var string[] + */ + protected $suggestions = array(); + /** * Initialize this page */ @@ -112,6 +119,13 @@ class AuthBackendPage extends Form )); } + foreach ($this->suggestions as $key => $suggestion) { + $element = $backendForm->getElement($key); + if ($element !== null) { + $element->setValue($suggestion); + } + } + $backendForm->getElement('name')->setValue('icingaweb2'); $this->addSubForm($backendForm, 'backend_form'); } @@ -231,4 +245,28 @@ class AuthBackendPage extends Form ) ); } + + /** + * Get default values for the subform's elements suggested by a previous step + * + * @return string[] + */ + public function getSuggestions() + { + return $this->suggestions; + } + + /** + * Set default values for the subform's elements suggested by a previous step + * + * @param string[] $suggestions + * + * @return $this + */ + public function setSuggestions(array $suggestions) + { + $this->suggestions = $suggestions; + + return $this; + } } diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index d8b0edcd5..f8f10ef2f 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -132,17 +132,17 @@ class WebWizard extends Wizard implements SetupWizard if ($page->getName() === 'setup_requirements') { $page->setWizard($this); } elseif ($page->getName() === 'setup_authentication_backend') { + /** @var AuthBackendPage $page */ + $authData = $this->getPageData('setup_authentication_type'); if ($authData['type'] === 'db') { $page->setResourceConfig($this->getPageData('setup_auth_db_resource')); } elseif ($authData['type'] === 'ldap') { $page->setResourceConfig($this->getPageData('setup_ldap_resource')); - if (! $this->hasPageData('setup_authentication_backend') && ! $request->isPost()) { - $suggestions = $this->getPageData('setup_ldap_discovery'); - if (isset($suggestions['backend'])) { - $page->populate($suggestions['backend']); - } + $suggestions = $this->getPageData('setup_ldap_discovery'); + if (isset($suggestions['backend'])) { + $page->setSuggestions($suggestions['backend']); } if ($this->getDirection() === static::FORWARD) {