Examples
Each example is a small PHP project in examples/: a composer.json, a run.php that builds a form and prints the HTML, and expected-output.txt with that HTML. Each page shows the code, a preview of the HTML with Bootstrap 3.4.1 CSS and the HTML itself.
- Three layoutsOne contact form rendered by the horizontal, vertical and inline renderer.
- Every control typeText, number, date, select, checkbox and radio lists, uploads, hidden fields and three kinds of buttons.
- Inline filterA GET filter above an order list, on one line.
- Validation errorsA registration form submitted with invalid values: alert, has-error and help blocks.
- Checkout with groupsFieldsets with legends and descriptions, radio lists and help texts.
- Button stylesPrimary, default and your own btn classes, string, array and addClass().
- Custom wrappersA col-md-4 + col-md-8 grid, a required marker, browser validation and one element per error.
- Manual renderingA sign-in form rendered part by part into a Bootstrap panel by a decorating renderer.
Running an example
All examples need PHP 8.4 or newer and Composer. They do not need a web server, a database or a network connection except for composer install:
git clone https://github.com/tomaj/nette-bootstrap-form.git
cd nette-bootstrap-form/examples/layouts
composer install
php run.phpUntil 3.0.0 is tagged, the examples require tomaj/nette-bootstrap-form: dev-master with "minimum-stability": "dev" and "prefer-stable": true; after the release they switch to ^3.0.
How the examples are tested
The Examples workflow runs every example on each push and pull request:
examples/ci/example.sh <name>copies the example to a temporary directory.examples/ci/use-local-bootstrap-form.shadds the repository root as a Composer path repository, installs the package from it and fails ifvendor/holds anything else. So a pull request runs the examples against its own code.php run.phpprints the HTML, which must be byte for byte the same asexpected-output.txt(diff -u).
The previews on these pages are built from the same expected-output.txt files when the site is built (docs/scripts/previews.mjs), so a preview always shows the HTML that CI has checked. Run an example against your checkout with examples/ci/example.sh layouts; after an intended change in the output, examples/ci/example.sh --update layouts writes the new expected-output.txt.
The PHP snippets on the other pages of this site are run by tests/DocsSnippetsTest.php in the PHPUnit suite, and their documented output is compared too.