Merge branch 'feature/wizard-step-logging-configuration-6129'

This commit is contained in:
Matthias Jentsch 2014-05-12 16:11:56 +02:00
commit 5da5dde602
1 changed files with 24 additions and 2 deletions

View File

@ -30,7 +30,7 @@
namespace Icinga\Form\Config;
use Zend_Config;
use \Zend_Config;
use Icinga\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Web\Form\Validator\WritablePathValidator;
@ -116,7 +116,19 @@ class LoggingForm extends Form
'required' => true,
'label' => t('Application Prefix'),
'helptext' => t('The name of the application by which to prefix syslog messages.'),
'value' => $loggingConfig->get('application', 'icingaweb')
'value' => $loggingConfig->get('application', 'icingaweb'),
'validators' => array(
array(
'Regex',
false,
array(
'pattern' => '/^[^\W]+$/',
'messages' => array(
'regexNotMatch' => 'The application prefix cannot contain any whitespaces.'
)
)
)
)
)
);
$this->addElement(
@ -151,6 +163,16 @@ class LoggingForm extends Form
$this->setSubmitLabel('{{SAVE_ICON}} Save Changes');
}
public function isValid($data) {
foreach ($this->getElements() as $key => $element) {
// Initialize all empty elements with their default values.
if (!isset($data[$key])) {
$data[$key] = $element->getValue();
}
}
return parent::isValid($data);
}
/**
* Return a Zend_Config object containing the state defined in this form
*