Skip to content

About

Bootstrap renderers (horizontal, vertical, inline) for Nette Forms.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

28 stars

Watchers

5 watching

Forks

Repository files navigation

Nette Bootstrap Form

Bootstrap renderers (horizontal, vertical, inline) for Nette Forms

Documentation: https://tomaj.github.io/nette-bootstrap-form/

Getting started · Renderers · API reference · Changelog

Latest Stable Version CI Coverage Status PHPStan OpenSSF Scorecard Documentation License PHP Version

What is Nette Bootstrap Form?

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 in col-sm-3, controls in col-sm-9)
  • BootstrapVerticalRenderer: the default Bootstrap layout, label above the control
  • BootstrapInlineRenderer: 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.

Installation

This library requires PHP 8.4 or later and nette/forms 3.2 or later.

composer require tomaj/nette-bootstrap-form

Usage

use 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.

Upgrading

See UPGRADE-3.0.md for upgrading from 2.x and CHANGELOG.md for all changes.

Contributing

See CONTRIBUTING.md. Everyone taking part follows the Code of Conduct.

Security

Report vulnerabilities in private, as described in SECURITY.md. Do not open a public issue.

License

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).

About

Bootstrap renderers (horizontal, vertical, inline) for Nette Forms.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

28 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages