diff --git a/lib/Entity/Schedule.php b/lib/Entity/Schedule.php index c76263d78a..7649615986 100644 --- a/lib/Entity/Schedule.php +++ b/lib/Entity/Schedule.php @@ -765,6 +765,10 @@ public function validate() if ($this->isPriority < 0) { throw new InvalidArgumentException(__('Priority must be 0 or a positive number'), 'isPriority'); } + // Check max plays per hour is positive + if ($this->maxPlaysPerHour < 0) { + throw new InvalidArgumentException(__('Maximum plays per hour must be 0 or a positive number'), 'maxPlaysPerHour'); + } // Run some additional validation if we have a recurrence type set. if (!empty($this->recurrenceType)) { diff --git a/views/schedule-form-add.twig b/views/schedule-form-add.twig index cd36778700..1c9aeda8d8 100644 --- a/views/schedule-form-add.twig +++ b/views/schedule-form-add.twig @@ -237,7 +237,7 @@ {% set title %}{% trans "Maximum plays per hour" %}{% endset %} {% set helpText %}{% trans "Limit the number of times this event will play per hour on each display. For unlimited plays set to 0." %}{{ forms.playerCompat("R308", "", "", "", "R306", "") }}{% endset %} - {{ forms.number("maxPlaysPerHour", title, 0, helpText, 'max-plays-control') }} + {{ forms.number("maxPlaysPerHour", title, 0, helpText, 'max-plays-control', "", "", "", "0") }} {% set title %}{% trans "Run at CMS Time?" %}{% endset %} {% set helpText %}{% trans "When selected, your event will run according to the timezone set on the CMS, otherwise the event will run at Display local time" %}{% endset %} diff --git a/views/schedule-form-edit.twig b/views/schedule-form-edit.twig index 0dbd8f5c90..f2907a7790 100644 --- a/views/schedule-form-edit.twig +++ b/views/schedule-form-edit.twig @@ -234,7 +234,7 @@ {% set title %}{% trans "Maximum plays per hour" %}{% endset %} {% set helpText %}{% trans "Limit the number of times this event will play per hour on each display. For unlimited plays set to 0." %}{{ forms.playerCompat("R308", "", "", "", "R306", "") }}{% endset %} - {{ forms.number("maxPlaysPerHour", title, event.maxPlaysPerHour, helpText, 'max-plays-control') }} + {{ forms.number("maxPlaysPerHour", title, event.maxPlaysPerHour, helpText, 'max-plays-control', "", "", "", "0") }} {% set title %}{% trans "Run at CMS Time?" %}{% endset %} {% set helpText %}{% trans "When selected, your event will run according to the timezone set on the CMS, otherwise the event will run at Display local time" %}{% endset %}