Files
nette-vite/app/ui/Form/BaseForm.php
2022-03-12 16:25:30 +01:00

32 lines
655 B
PHP
Executable File

<?php declare(strict_types = 1);
namespace App\UI\Form;
use Nette\Application\UI\Form;
use Nette\Forms\Controls\TextInput;
class BaseForm extends Form
{
public function addFloat(string $name, ?string $label = null): TextInput
{
$input = self::addText($name, $label);
$input->addCondition(self::FILLED)
->addRule(self::MAX_LENGTH, null, 255)
->addRule(self::FLOAT);
return $input;
}
public function addNumeric(string $name, ?string $label = null): TextInput
{
$input = self::addText($name, $label);
$input->addCondition(self::FILLED)
->addRule(self::MAX_LENGTH, null, 255)
->addRule(self::NUMERIC);
return $input;
}
}