CommandArgument: always show and handle skip_key

This also allows to wipe the argument_name on modification

fixes #682
This commit is contained in:
Thomas Gelf 2017-09-04 10:01:11 +02:00
parent c55d147ff0
commit 54e17237e3

View File

@ -106,6 +106,15 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
) )
)); ));
$this->addBoolean('skip_key', array(
'label' => $this->translate('Skip key'),
'description' => $this->translate(
'Whether the parameter name should not be passed to the command.'
. ' Per default, the parameter name (e.g. -H) will be appended,'
. ' so no need to explicitly set this to "No".'
)
));
$this->addBoolean('required', array( $this->addBoolean('required', array(
'label' => $this->translate('Required'), 'label' => $this->translate('Required'),
'required' => false, 'required' => false,
@ -139,11 +148,9 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
{ {
$object = $this->object(); $object = $this->object();
$cmd = $this->commandObject; $cmd = $this->commandObject;
if (! $object->hasBeenLoadedFromDb()) { if ($object->get('argument_name') === null) {
if ($object->get('argument_name') === null) { $object->set('skip_key', true);
$object->set('skip_key', true); $object->set('argument_name', $cmd->getNextSkippableKeyName());
$object->set('argument_name', $cmd->getNextSkippableKeyName());
}
} }
if ($object->hasBeenModified()) { if ($object->hasBeenModified()) {