Basic functionality

This commit is contained in:
2022-03-12 16:25:30 +01:00
parent f3beaa64cf
commit acc21b7b24
137 changed files with 12647 additions and 5089 deletions

31
app/ui/Form/BaseForm.php Executable file
View File

@@ -0,0 +1,31 @@
<?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;
}
}

23
app/ui/Form/FormFactory.php Executable file
View File

@@ -0,0 +1,23 @@
<?php declare(strict_types = 1);
namespace App\UI\Form;
final class FormFactory
{
private function create(): BaseForm
{
return new BaseForm();
}
public function forFrontend(): BaseForm
{
return $this->create();
}
public function forBackend(): BaseForm
{
return $this->create();
}
}

View File

@@ -0,0 +1,53 @@
<?php declare(strict_types = 1);
namespace App\UI\Form;
use Nette\Application\UI\Form;
use Nette\Forms\Controls\TextInput;
use App\Model\Database\EntityManager;
use App\Model\Database\Entity\Dictionary;
use App\Model\Database\Entity\Translation;
class SearchFormData
{
/** @var string */
public $string;
/** @var int */
public $translation;
/** @var string */
public $clen;
}
class SearchFormFactory extends Form
{
use \Nette\SmartObject;
public EntityManager $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function create($select,SearchFormData $data = null): Form
{
if ($data == null) $data = new SearchFormData();
$form = new Form;
$form->addText('string', 'Výraz')
->setRequired('Zadajte výray');
$form->addSelect('translation', 'Preklad', $select)
->setDefaultValue(1)
->setRequired('Vyberte slovnik');
$form->addText('clen', 'Clen', 5);
$form->addSubmit('search', 'Vyhaľadaj');
return $form;
}
public function searchFormSubmmited(Form $form, SearchFormData $data)
{
}
}