Fix dis/enabling of feature commands of multi-selected hosts or services.

In case of elements other than CheckboxElement $element->getValue() must be used instead of $element->isChecked().
This commit is contained in:
raviks789 2021-11-12 11:51:21 +01:00 committed by Johannes Meyer
parent 13669fd1ae
commit 2a2ac29589

View file

@ -8,6 +8,7 @@ use Icinga\Module\Icingadb\Command\Object\ToggleObjectFeatureCommand;
use Icinga\Module\Icingadb\Common\Auth;
use Icinga\Module\Icingadb\Forms\Command\CommandForm;
use Icinga\Web\Notification;
use ipl\Html\FormElement\CheckboxElement;
use ipl\Orm\Model;
use ipl\Web\FormDecorator\IcingaFormDecorator;
@ -160,7 +161,11 @@ class ToggleObjectFeaturesForm extends CommandForm
protected function getCommand(Model $object): \Generator
{
foreach ($this->features as $feature => $spec) {
$featureState = $this->getElement($feature)->isChecked();
if ($this->getElement($feature) instanceof CheckboxElement) {
$featureState = $this->getElement($feature)->isChecked();
} else {
$featureState = $this->getElement($feature)->getValue();
}
if (
! $this->isGrantedOn($spec['permission'], $object)