Releases: torchbox/tbxforms
v4.2.0
v4.1.0
v4.0.0
What's changed
Changed
- Renamed
tbx
template directory and crispy forms template pack totbxforms
[#92]
Fixed
- Conditional fields not working properly when there are multiple elements inspecting the same driving field [#91]
Removed
- IE11 support [#91]
Full Changelog: v3.0.0...v4.0.0
Upgrade considerations
Template pack and path have been renamed from tbx
is now tbxforms
You must update references from tbx
to tbxforms
. This change makes it clearer what template pack is used, and makes overriding templates easier.
Change this:
CRISPY_ALLOWED_TEMPLATE_PACKS = ["tbx"]
CRISPY_TEMPLATE_PACK = "tbx"
To:
CRISPY_ALLOWED_TEMPLATE_PACKS = ["tbxforms"]
CRISPY_TEMPLATE_PACK = "tbxforms"
If you have overridden any templates, you will need to rename your tbx
directory to tbxforms
.
Dropped javascript support for IE11
The conditional fields JS previously had a pollyfil for IE11, which has now been removed.
v3.0.0
What's changed
Developer
- Guidance on how to update
govuk-frontend
[#80]
Pinned packages updated
govuk-frontend
from 3.13.0 (possibly) to 5.4.1 [#80]
Removed
Several CSS classes/mixins have been removed/renamed in this release, some of
which are vendor changes in govuk-frontend
.
Unfortunately, the initial release of tbxforms customised the styles from
govuk-frontend
without documentation - including which version was used as a
base. As a result, it's hard to distinguish between variables/mixins we
added which have now been removed and those which GDS have removed over time.
However, variables which have now been removed from our _variables.scss are:
$tbxforms-border-colour-conditional
(no longer configurable; now using GDS'$tbxforms-border-colour
) [#80]$tbxforms-border-width-conditional
(no longer configurable; now using GDS'$tbxforms-border-width
) [#80]$tbxforms-weight--bold
(use$tbxforms-font-weight-bold
instead) [#80]$tbxforms-weight--normal
(use$tbxforms-font-weight-regular
instead) [#80]$tbxforms-grid
(no longer configurable; now using GDS' default spacing) [#80]$tbxforms-spacer
(no longer configurable; now using GDS' default spacing) [#80]$tbxforms-in-field-spacer
(no longer configurable; now using GDS' default spacing) [#80]$tbxforms-form-group-spacer
(no longer configurable; now using GDS' default spacing) [#80]$tbxforms-base-font-size
(use$tbxforms-typography-scale
instead) [#80]$tbxforms-base-line-height
(use$tbxforms-typography-scale
instead) [#80]$tbxforms-font-sizes
(use$tbxforms-typography-scale
instead) [#80]
Full Changelog: v2.1.0...v3.0.0
Upgrade considerations
A lot of styling has been updated
This release includes a lot of updates to styles as the govuk-frontend
has been updated from 3.13.0 (possibly) to 5.4.1. You should notice minor changes in your projects, though you may not need to make any updates.
Remove unused CSS variables
If you use any of the variables listed above, you should remove/update those references. Suggestions have been added for the closest alternative where applicable/possible.
Hint text for fields now uses a block-level element
Hint text for fields used to use a <span>
element, though this differs from what GDS use themselves. As a result, this version changes this so hint text for fields now uses a <p>
element.
This allows GDS' styles for hint text to be applied correctly.
v2.1.0
What's changed
Changed
- Allow required fields to be highlighted instead of optional ones [#78]
- Allow markup in error messages [#79]
Full Changelog: v2.0.1...v2.1.0
Upgrade considerations
Highlight required fields instead of optional ones
You can now invert the default behaviour and append asterisks to required fields instead of appending "(optional)" to optional fields.
If TBXFORMS_HIGHLIGHT_REQUIRED_FIELDS=False
(or unset), optional fields will
have "(optional)" appended to their labels. This is the default behaviour and
recommended by GDS.
If TBXFORMS_HIGHLIGHT_REQUIRED_FIELDS=True
, required fields will have an
asterisk appended to their labels and optional fields will not be highlighted.
You can also style these markers by targeting these CSS classes:
.tbxforms-field_marker--required
.tbxforms-field_marker--optional
v2.0.1
v2.0.0
What's changed
Added
Changed
django-crispy-forms
updated to 2.1.x [#61]
Deprecated
- Django support for 2.2, 3.0, and 3.1 [#61]
TBXFORMS_ALLOW_HTML_LABEL
,TBXFORMS_ALLOW_HTML_HELP_TEXT
, andTBXFORMS_ALLOW_HTML_BUTTON
settings (developers must now mark strings as safe to render markup within templates) [#61] [#62]sass
support for <1.33.0 [#60]
Fixed
- Documentation referencing an incorrect CSS import path
Security
|safe
is no longer applied within templates [#61]
See full changelog.
Upgrade considerations
Strings are now escaped by default
To show unescaped markup, you must mark any strings as safe (e.g. with mark_safe()
) as values are now escaped by default. Previously, they were conditionally escaped based on the values of TBXFORMS_ALLOW_HTML_LABEL
, TBXFORMS_ALLOW_HTML_HELP_TEXT
, and TBXFORMS_ALLOW_HTML_BUTTON
settings.
This applies to label
, help_text
, hint
(for select and checkbox fields), and value
for button fields.
You should remove the following settings:
TBXFORMS_ALLOW_HTML_LABEL
TBXFORMS_ALLOW_HTML_HELP_TEXT
TBXFORMS_ALLOW_HTML_BUTTON
New contributors
- @olivierphi made their first contribution in #61
- @RealOrangeOne made their first contribution in #60
v1.1.0
What's changed
Added
- Support for dividers on checkbox fields
Changed
- form.helper (
FormHelper
) changed from a static@property
to the form's__init__
method to allow changes at runtime - Update documentation and examples to use
Field
subclass methods (e.g.Field.select
) to avoid passingcontext
dictionary toField
(https://crispy-forms-gds.readthedocs.io/en/latest/reference/layout/field.html) BaseForm
renamed toTbxFormsMixin
to more accurately convey what it is- Styles no longer depend on the form having the
.tbxforms
class (note: the JavaScript still does!)
Developer
- Added template linting to CI using
djlint
- Added syrupy snapshot testing and removed the static/manual HTML fixtures
- We're now testing across Django versions 2.2 - 4.0 and Python versions 3.8 - 3.11 using
tox
Fixed
Field.select
label size and tag can be changedDateInputField
no longer raises aValueError
when given invalid input (aValidationError
is raised instead)DateInputField
withrequired=False
no longer raises aValueError
when no values are passedDateInputField
no longer errors withOverflowError
when large values are passed
Upgrade considerations
BaseForm
is now named TbxFormsMixin
You must update references from tbxforms.forms.BaseForm
to tbxforms.forms.TbxFormsMixin
. This change better conveys what TbxFormsMixin
is - a mixin that does not inherit from any of Django's base form classes.
FormHelper
is now added via the TbxFormsMixin.__init__
method instead of via a helper
property
You should replace any form.helper
properties with form helpers that are instantiated via the form __init__
method - e.g.:
From:
class YourSexyForm(...):
...
@property
def helper(self):
fh = super().helper
# Use HTML5 validation
fh.html5_required = True
# Add a submit button
fh.layout.extend([
Button.primary(
name="submit",
type="submit",
value="Submit",
)
])
return fh
To:
class YourSexyForm(...):
...
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Use HTML5 validation
self.helper.html5_required = True
# Add a submit button
self.helper.layout.extend([
Button.primary(
name="submit",
type="submit",
value="Submit",
)
])
You must not instantiate your own FormHelper()
- you should inherit from the existing helper (self.helper
).
While using a static helper
property is still supported (as this is core Django Crispy Forms behaviour), tbxforms
no longer provides a helper
property to inherit from.
This change allows you to change the FormHelper
on the go - see https://django-crispy-forms.readthedocs.io/en/latest/dynamic_layouts.html for more information on this.
In most cases, Field(...)
layout slices should now subclass specific fields, e.g. Field.text(...)
You should update all Field(...)
layout slices to use one of the more specific subclasses:
Field.checkbox(...)
Field.checkboxes(...)
Field.radios(...)
Field.select(...)
Field.text(...)
Field.textarea(...)
See https://github.com/torchbox/tbxforms/blob/main/tbxforms/layout/fields.py for more information.
While Field(...)
is still supported, the behaviour is not guaranteed. Using one of the more specific subclasses will align your fields with tbxforms
and allow you to leverage key functionality more easily.
tbxforms
styles are no longer nested under the .tbxforms
class
While all tbxforms
forms must still have a tbxforms
class in order for conditional fields to work, the associated styles are no longer nested underneath the .tbxforms
class.