adt / nette-forms-components
Requires
- php: >=8.3
- nette/application: ^3.0
- nette/forms: ^3.2.3
- nette/utils: ^3.0 | ^4.0
Requires (Dev)
- contributte/translation: ^2.0
- nette/neon: ^3.4 | ^4.0
- nette/tester: ^2.5
Suggests
- contributte/translation: Czech validation messages of Nette Forms (NetteFormsComponentsExtension)
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v2.9
- v2.8
- v2.7
- v2.6
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.27
- v2.2.26
- v2.2.25
- v2.2.24
- v2.2.23
- v2.2.22
- v2.2.21
- v2.2.20
- v2.2.19
- v2.2.18
- v2.2.17
- v2.2.16
- v2.2.15
- v2.2.14
- v2.2.13
- v2.2.12
- v2.2.11
- v2.2.10
- v2.2.9
- v2.2.8
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0
- v1.x-dev
- v1.12.6
- v1.12.5
- v1.12.4
- v1.12.3
- v1.12.2
- v1.12.1
- v1.12
- v1.11.1
- v1.11
- v1.10.2
- v1.10.1
- v1.10
- v1.9.6
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8
- v1.7.1
- v1.7
- v1.6.11
- v1.6.10
- v1.6.9
- v1.6.8
- v1.6.7
- v1.6.6
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5
- v1.4
- v1.3
- v1.2.1
- v1.2
- v1.1
- v1.0.2
- v1.0.1
- v1.0
- dev-feat/input-group-buttons
- dev-fix/csp-error-script
- dev-f-password-reveal-csp-nonce
- dev-f-password-reveal-no-value-by-default
- dev-f-password-reveal-value
- dev-f-password-reveal-input
- dev-adding-template-for-replicator
- dev-add-form-switcher
This package is auto-updated.
Last update: 2026-11-14 16:10:00 UTC
README
Installation
composer require adt/nette-forms-components
ADT\Forms\Form
Nette\Application\UI\Form subclass using ADT\Forms\BoostrapFormRenderer to render a form in Bootstrap 5 (default) or 4.
Overrides addError method (the parent method does not use the translator lazy).
Have @method annotations for all ADT Nette Forms components so PhpStorm auto completion should work out of the box.
ADT\Forms\BoostrapFormRenderer
Can be used on its own, without using ADT\Forms\Form (for example in Ublaboo\DataGrid\DataGrid::createComponentFilter method, which creates Nette\Application\UI\Form instance)
Can be switch to Bootstrap 4 calling ADT\Forms\BoostrapFormRenderer::$version = ADT\Forms\BootstrapFormRender::VERSION_4; (for example in your BasePresenter::beforeRender method).
If it's an AJAX request and the form is not valid, only snippets with error messages will be sent back to browser (without rendering the form).
Every error container carries data-adt-errors-for with the HTML id of its control (or form). Next to control errors an inline <script> is rendered that adds is-invalid to the control (and to its parent for radio/checkbox lists and input groups). When the Content-Security-Policy of the response would block it anyway (script-src-elem, script-src or default-src without 'unsafe-inline', or with a nonce, hash or 'strict-dynamic'), the script is omitted. A nonce does not help here, because error snippets arrive over AJAX with a nonce of a different request. The classes are then set by the SubmitForm component of adt-js-components from data-adt-errors-for.
If you need, you can use static methods ADT\Forms\BoostrapFormRenderer::makeBootstrap and ADT\Forms\BoostrapFormRenderer::sendErrorPayload manually (for example in \Ublaboo\DataGrid\DataGrid::setItemsDetailForm, where the container is created dynamically).
You can use ->setOption('description', 'Description text') to use field description.
You can use ->setOption('prepend', 'Text to prepend') or ->setOption('append', 'Text to append') to use proper inpur group styles.
Containers
Can be used on their own, without using ADT\Forms\Form.
The addStaticContainer and addDynamicContainer methods are registered automatically when the package is installed (composer autoload files, src/register.php) - no BaseContainer::register() in the bootstrap is needed (calling it is harmless).
ADT\Forms\Controls\PasswordRevealInput
Password input with an eye button to reveal the value. The addPasswordReveal($name, $renderValue, $label) method is registered automatically (see Containers).
The behaviour is driven by an inline <script> rendered next to the input. Since it is built in PHP outside of Latte, n:nonce cannot reach it, so the control reads the nonce from the already sent Content-Security-Policy (or Content-Security-Policy-Report-Only) header itself and puts it on the element. Without a presenter or without CSP the attribute is simply omitted.
Tests
composer install && composer tester
Czech validation messages
The default validation messages of Nette Forms go through the translator of the form. The package
ships them in Czech (src/lang/messages.cs.neon, the English message is the key) for
contributte/translation:
extensions: netteFormsComponents: ADT\Forms\DI\NetteFormsComponentsExtension
Forms in other locales keep the messages of Nette (or of their own catalog).