anytech / bootstrap-forms
Bootstrap 5 markup for SilverStripe 6 frontend forms
Package info
github.com/anytech/bootstrap-forms
Language:Scheme
Type:silverstripe-vendormodule
pkg:composer/anytech/bootstrap-forms
Requires
- php: ^8.3
- silverstripe/admin: ^3.0
- silverstripe/framework: ^6.0
This package is auto-updated.
Last update: 2026-08-06 07:06:51 UTC
README
Makes SilverStripe 6 frontend forms render Bootstrap 5 markup automatically. No per-site template work: install, flush, done. The module ships no CSS or JS; it assumes the site already loads Bootstrap 5.
Requirements
- PHP 8.3+
- silverstripe/framework ^6.0
- silverstripe/admin ^3.0
Installation
Add the package to the project's composer repositories (private package), then:
composer require anytech/bootstrap-forms
Run a flush (/dev/build?flush=1 or ?flush=1) so the template manifest picks up the overrides.
What it does
Two extensions applied via _config/extensions.yml:
FormFieldExtensiononSilverStripe\Forms\FormField: appends Bootstrap classes to the rendered element through theupdateAttributeshook, so holder wrapper classes stay untouched.FormExtensiononSilverStripe\Forms\Form: exposes$MessageAlertClassto templates, mapping form message types toalert-danger,alert-success,alert-info,alert-warning.
Template overrides in templates/SilverStripe/Forms/ replace the framework defaults (module templates outrank silverstripe/framework in the $default theme set; site themes still outrank this module):
| Template | Change |
|---|---|
Includes/Form.ss |
Form message as .alert with role="alert", actions in .btn-toolbar.gap-2 |
FormField_holder.ss |
.mb-3 wrapper, .form-label, .invalid-feedback, .form-text |
CheckboxField_holder.ss |
.form-check wrapper with .form-check-label |
CheckboxField_holder_small.ss |
.form-check variant for field groups |
OptionsetField.ss / CheckboxSetField.ss |
li.form-check with .form-check-input / .form-check-label |
OptionsetField_holder.ss / CheckboxSetField_holder.ss |
fieldset wrapper with the group title as legend.col-form-label.pt-0, plus feedback/description blocks |
Field class mapping:
| Field | Class |
|---|---|
| Text-like fields, textarea, file, date/time | form-control |
| DropdownField, GroupedDropdownField, ListboxField | form-select |
| CheckboxField | form-check-input |
OptionsetField, CheckboxSetField (the ul) |
list-unstyled |
| FormAction | btn plus default variant |
| Any field with a validation message | is-invalid |
Skipped entirely: HiddenField, dataless fields (literal, header, label), GridField, TreeDropdownField, SearchableDropdownField, SearchableMultiDropdownField, and everything rendered inside the CMS (guarded by a LeftAndMain controller check; the cms-forms admin theme also outranks these templates in the admin).
Configuration
Default button variant is btn-primary. Change it per site:
Anytech\BootstrapForms\FormFieldExtension: button_variant: btn-outline-secondary
Per-action variants win over the default: any action that already carries a btn-* class (via addExtraClass) keeps it and the default variant is not added.
Overriding
A site theme template at themes/<theme>/templates/SilverStripe/Forms/... overrides this module as usual.