Bootstrap renderers (horizontal, vertical, inline) for Nette Forms
Documentation: https://tomaj.github.io/nette-bootstrap-form/
Getting started · Renderers · API reference · Changelog
Nette Bootstrap Form is a set of form renderers for Nette Forms that output Bootstrap 3 form markup. Set a renderer on a form and every control gets the Bootstrap classes and wrappers, with no template code:
BootstrapRenderer: horizontal form (form-horizontal, labels incol-sm-3, controls incol-sm-9)BootstrapVerticalRenderer: the default Bootstrap layout, label above the controlBootstrapInlineRenderer: inline form (form-inline)
Text inputs, text areas and selects get form-control, the first button btn btn-primary and the others btn btn-default (buttons that already have a btn class are left alone), checkboxes and radio lists are wrapped for Bootstrap, and errors are shown in an alert alert-danger box.
This library requires PHP 8.4 or later and nette/forms 3.2 or later.
composer require tomaj/nette-bootstrap-formuse Nette\Forms\Form;
use Tomaj\Form\Renderer\BootstrapRenderer;
$form = new Form();
$form->addText('name', 'Name')->setRequired();
$form->addSubmit('send', 'Send');
$form->setRenderer(new BootstrapRenderer());
echo $form;Use BootstrapVerticalRenderer or BootstrapInlineRenderer the same way. All three take an optional $novalidate argument (default true); pass false to keep the browser's HTML5 validation. Read the documentation for the rendered markup, button classes and customizing the wrappers.
See UPGRADE-3.0.md for upgrading from 2.x and CHANGELOG.md for all changes.
See CONTRIBUTING.md. Everyone taking part follows the Code of Conduct.
Report vulnerabilities in private, as described in SECURITY.md. Do not open a public issue.
nette-bootstrap-form is licensed under the GNU Lesser General Public License, version 2.0 or later (LGPL-2.0-or-later, as declared in composer.json).