designtopack/public/kirby/src/Form/Mixin/Min.php

34 lines
470 B
PHP
Raw Normal View History

2024-07-10 16:10:33 +02:00
<?php
namespace Kirby\Form\Mixin;
trait Min
{
protected int|null $min;
public function min(): int|null
{
// set min to at least 1, if required
if ($this->required === true) {
return $this->min ?? 1;
}
2024-07-10 16:10:33 +02:00
return $this->min;
}
2025-02-07 17:11:37 +01:00
protected function setMin(int|null $min = null)
2024-07-10 16:10:33 +02:00
{
$this->min = $min;
}
public function isRequired(): bool
{
// set required to true if min is set
if ($this->min) {
return true;
}
return $this->required;
}
2024-07-10 16:10:33 +02:00
}