mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
IcingaCommandArgumentForm: detect custom variables
This commit is contained in:
parent
88d87b1e5c
commit
ad27ab206d
@ -27,6 +27,19 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
|
|||||||
|
|
||||||
$this->addHidden('value_format', 'string'); // expression, json?
|
$this->addHidden('value_format', 'string'); // expression, json?
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function beforeValidation($data = array())
|
||||||
|
{
|
||||||
|
if (isset($data['argument_value']) && $value = $data['argument_value']) {
|
||||||
|
if (preg_match_all('/\$([a-z0-9_]+)\$/', $value, $m, PREG_PATTERN_ORDER)) {
|
||||||
|
foreach ($m[1] as $var) {
|
||||||
|
$this->addCustomVariable($var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$this->optionalBoolean(
|
$this->optionalBoolean(
|
||||||
'required',
|
'required',
|
||||||
@ -36,4 +49,22 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
|
|||||||
*/
|
*/
|
||||||
$this->addElement('submit', $this->translate('Store'));
|
$this->addElement('submit', $this->translate('Store'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addCustomVariable($varname)
|
||||||
|
{
|
||||||
|
$a = new \Zend_Form_SubForm();
|
||||||
|
$a->addElement('note', 'title', array(
|
||||||
|
'label' => sprintf($this->translate('Custom Variable "%s"'), $varname),
|
||||||
|
));
|
||||||
|
|
||||||
|
$a->addElement('text', 'description', array(
|
||||||
|
'label' => $this->translate('Description'),
|
||||||
|
'required' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$a->addElement('text', 'default_value', array(
|
||||||
|
'label' => $this->translate('Default value'),
|
||||||
|
));
|
||||||
|
$this->addSubForm($a, 'cv_' . $varname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user