aipng / forms
Reusable form control.
0.4
2019-11-11 14:45 UTC
Requires
- php: >=7.1
- nette/application: ^3.0
- nette/forms: ^3.0
Requires (Dev)
- latte/latte: ^2.4
- phpstan/phpstan: ^0.11
- phpstan/phpstan-nette: ^0.11.1
- phpstan/phpstan-phpunit: ^0.11
- phpunit/phpunit: ^7.5 || ^8.0
README
"Form as a component" control. Form should be defined in createComponentForm
method.
Simple structure:
/my-app/src/
templates/MyForm.latte
MyForm.php
MyForm.latte
MyForm.latte - customized form template (when needed)
{form form} manual rendering of form controls ... {/form}
MyForm.php
final class MyForm extends \AipNg\Forms\BaseFormControl { public function createComponentForm(): \Nette\Application\UI\Form { $form = ... return $form; } }
Usage in presenter
// in presenter class MyPresenter public function createComponentMyForm() { return new MyForm; } public function actionEdit() { $this['myForm']->setDefaults([ ... ]); }
Latte
Input description macro helps to show control's description in template when using manual rendering.
Register in config.neon:
latte: macros: - AipNg\Latte\Macro\InputDescriptionMacro::register
Just use anywhere in form template
{inputDescription $controlName}