FAQ
Does it work with Bootstrap 4 or 5?
No. The renderers output Bootstrap 3 markup: form-group, control-label, help-block, has-error, btn-default, div.checkbox. Bootstrap 4 and 5 use other classes (form-check, invalid-feedback, is-invalid, mb-3), so most of the look would be lost. You can get part of the way by changing $wrappers, but the button and checkbox classes are fixed in the code. For Bootstrap 5 a dedicated renderer is the better choice.
Which nette/forms versions are supported?
3.2 and newer 3.x versions ("nette/forms": "^3.2"), on PHP 8.4 or newer. CI runs the tests with the lowest and the latest allowed versions.
Why does my colour input not look like the other inputs?
The renderers add no class to addColor(), because Bootstrap 3 has no style for colour inputs and form-control would stretch the swatch to a full-width box. Date and time inputs (addDate(), addTime(), addDateTime()) get form-control since 3.0; in 2.x they got nothing. See Controls.
Why is my button not blue?
Only the first button without a btn class gets btn-primary. If an earlier button has no class, it is the primary one. If your button has any class containing btn (even btn-lg alone), the renderer leaves it as it is; give it the full classes, such as btn btn-primary btn-lg. See Buttons.
Can I extend a renderer?
Not since 3.0: the classes are final. Configure $wrappers on an instance (Customizing) or wrap the renderer in your own Nette\Forms\FormRenderer (Wrapping the renderer). Upgrading to 3.0 shows both with before and after code.
Why are the Bootstrap classes missing when I render the form in Latte?
{form}, {label}, {input} and n:name render controls without calling the renderer. Only {control myForm}, echo $form and $form->render() use it. Write the classes in the template, or render parts with the renderer; see Nette application.
Where do the text and button classes come from?
From $wrappers (control .text, .submit, ...), inherited from Nette's default renderer. They have no meaning in Bootstrap; set those keys to null to drop them (Customizing).
Why does the browser not show its own validation bubbles?
The renderers add novalidate to the form by default, so Nette's validation shows the errors. Create the renderer with novalidate: false to keep the browser validation (HTML5 validation).
Can I render a form twice, or with two renderers?
Rendering the same form again with the same renderer gives the same HTML; the classes are not added twice. Rendering it with a different renderer keeps the classes of the first one (for example form-horizontal on the <form>), because they are stored on the form and its controls. Build a new form for each layout, as examples/layouts does.
Does the renderer escape my labels and values?
nette/forms escapes them, exactly as with the default renderer. Html objects are inserted as they are; see Security.
How do I put two inputs side by side?
The nextTo option renders two controls in one pair, but both are full-width form-controls. For a real row (an input group, two columns) render that part of the form by hand in Latte; see Several controls in one row.