diff --git a/application/forms/LdapDiscoveryForm.php b/application/forms/LdapDiscoveryForm.php index fc1625385..3e129934d 100644 --- a/application/forms/LdapDiscoveryForm.php +++ b/application/forms/LdapDiscoveryForm.php @@ -24,7 +24,6 @@ class LdapDiscoveryForm extends Form 'text', 'domain', array( - 'required' => true, 'label' => $this->translate('Search Domain'), 'description' => $this->translate('Search this domain for records of available servers.'), ) diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index addc40545..6dbec66da 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -3,7 +3,9 @@ namespace Icinga\Module\Setup\Forms; +use Zend_Validate_NotEmpty; use Icinga\Web\Form; +use Icinga\Web\Form\ErrorLabeller; use Icinga\Forms\LdapDiscoveryForm; use Icinga\Protocol\Ldap\Discovery; use Icinga\Module\Setup\Forms\LdapDiscoveryConfirmPage; @@ -55,15 +57,11 @@ class LdapDiscoveryPage extends Form $discoveryForm = new LdapDiscoveryForm(); $this->addElements($discoveryForm->createElements($formData)->getElements()); - $this->getElement('domain')->setRequired( - isset($formData['skip_validation']) === false || ! $formData['skip_validation'] - ); $this->addElement( 'checkbox', 'skip_validation', array( - 'required' => true, 'label' => $this->translate('Skip'), 'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.') ) @@ -82,19 +80,24 @@ class LdapDiscoveryPage extends Form if (false === parent::isValid($data)) { return false; } - if ($data['skip_validation']) { + if (isset($data['skip_validation']) && $data['skip_validation']) { return true; } - if (isset($data['domain'])) { + if (isset($data['domain']) && $data['domain']) { $this->discovery = Discovery::discoverDomain($data['domain']); if ($this->discovery->isSuccess()) { return true; } + + $this->addError( + sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) + ); + } else { + $labeller = new ErrorLabeller(array('element' => $this->getElement('domain'))); + $this->getElement('domain')->addError($labeller->translate(Zend_Validate_NotEmpty::IS_EMPTY)); } - $this->addError( - sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) - ); + return false; }