From 8fa8f4baf0c0206f2e458b172abc02beba7e3eb7 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 16 May 2023 15:15:01 +0200 Subject: [PATCH] AcknowledgeProblem|AddComment-Form: Don't show datepicker if `expire` checkbox is unchecked --- application/forms/Command/Object/AcknowledgeProblemForm.php | 6 ++---- application/forms/Command/Object/AddCommentForm.php | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/application/forms/Command/Object/AcknowledgeProblemForm.php b/application/forms/Command/Object/AcknowledgeProblemForm.php index 5ca70740..2229c839 100644 --- a/application/forms/Command/Object/AcknowledgeProblemForm.php +++ b/application/forms/Command/Object/AcknowledgeProblemForm.php @@ -126,22 +126,20 @@ class AcknowledgeProblemForm extends CommandForm ); $decorator->decorate($this->getElement('sticky')); - $acknowledgeExpire = (bool) $config->get('settings', 'acknowledge_expire', false); - $this->addElement( 'checkbox', 'expire', [ 'ignore' => true, 'class' => 'autosubmit', - 'value' => $acknowledgeExpire, + 'value' => (bool) $config->get('settings', 'acknowledge_expire', false), 'label' => t('Use Expire Time'), 'description' => t('If the acknowledgement should expire, check this option.') ] ); $decorator->decorate($this->getElement('expire')); - if ($acknowledgeExpire || $this->getPopulatedValue('expire') === 'y') { + if ($this->getElement('expire')->isChecked()) { $expireTime = new DateTime(); $expireTime->add(new DateInterval($config->get('settings', 'acknowledge_expire_time', 'PT1H'))); diff --git a/application/forms/Command/Object/AddCommentForm.php b/application/forms/Command/Object/AddCommentForm.php index af75f86e..85fbd665 100644 --- a/application/forms/Command/Object/AddCommentForm.php +++ b/application/forms/Command/Object/AddCommentForm.php @@ -82,7 +82,6 @@ class AddCommentForm extends CommandForm $decorator->decorate($this->getElement('comment')); $config = Config::module('icingadb'); - $commentExpire = (bool) $config->get('settings', 'comment_expire', false); $this->addElement( 'checkbox', @@ -90,14 +89,14 @@ class AddCommentForm extends CommandForm [ 'ignore' => true, 'class' => 'autosubmit', - 'value' => $commentExpire, + 'value' => (bool) $config->get('settings', 'comment_expire', false), 'label' => t('Use Expire Time'), 'description' => t('If the comment should expire, check this option.') ] ); $decorator->decorate($this->getElement('expire')); - if ($commentExpire || $this->getPopulatedValue('expire') === 'y') { + if ($this->getElement('expire')->isChecked()) { $expireTime = new DateTime(); $expireTime->add(new DateInterval($config->get('settings', 'comment_expire_time', 'PT1H')));