aipng / forms
可重用的表单控件。
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
"作为组件的表单"控件。表单应在 createComponentForm
方法中定义。
简单结构
/my-app/src/
templates/MyForm.latte
MyForm.php
MyForm.latte
MyForm.latte - 自定义表单模板(如有需要)
{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; } }
在presenter中使用
// in presenter class MyPresenter public function createComponentMyForm() { return new MyForm; } public function actionEdit() { $this['myForm']->setDefaults([ ... ]); }
Latte
输入描述宏有助于在手动渲染时在模板中显示控件描述。
在 config.neon 中注册
latte: macros: - AipNg\Latte\Macro\InputDescriptionMacro::register
在任何地方使用表单模板中
{inputDescription $controlName}