newforms v0.6.0 Release Notes
Release Date: 2014-05-07 // almost 10 years ago-
๐ฅ Breaking Changes
- ๐ Renamed
form.isBound
toform.isInitialRender
, which more accurately reflects usage of this property (it was always being used in Forms as!isBound
) - ๐ Changed
form.setData()
to no longer accept prefixed data by default. Added aprefixed
option argument which controls this and a newsetFormData()
method which replicates the old behaviour. This makessetData()
more user-friendly for use with controlled forms.
๐ New Features
- โ Added per-field validation as the user makes changes to the form, configured
by passing a
validation
option when constructing a Form, Field or FormSet. - โ Added toggling of creation of controlled React components, configured by
passing a
controlled
option when constructing a Form or FormSet. When using controlled components, form widgets reflect the state ofform.data
, so you can change what's displayed in the form by updating its data. - โ Added calling of a
onStateChange()
callback when provided - passed as an option when constructing a Form or FormSet - any time validation state may have changed as a result of updating user input from controlled components, or as a result of validation triggered by user interaction. This option becomes required when usingvalidation
orcontrolled
options. - โ Added support for partial updating (
form.updateData(partialData)
) and cleaning (form.partialClean(fieldNames)
) of data. - โ Added
form.reset(newInitial)
to reset a form back to its initial state, optionally providing new initial data in the process. - โ Added a
validate
option toform.setData()
to support setting incomplete data in a controlled form without triggering required field validation errors. - โ Added
form.validate(<form>)
as a convenience method for retrieving and validating input data from a<form>
- this removes a common step when hooking up full-formonSubmit
validation. - โ Added
form.isComplete()
to determine if all required fields have valid input data when validation is being performed interactively. - โ Added
.errorMessage()
and.errorMessages()
to BoundField as a convenience for accessing error message strings, instead of having to go through.errors()
and use the ErrorList API. - โ Added generation of a
validCssClass
in default rendering or when usingBoundField#cssClasses()
directly, if present on a form or its prototype. - โ Added a top-level
validateAll
utility method equivalent toform.validate()
but for multiple Forms and/or FormSets. - โ Added
Widget.prototype.needsInitialValue
to allow Widgets to always receive the initial value of a field in addition to user input to be rendered.
๐ Changes
- ๐ Changed default widget attributes to always have a
key
property, to prevent fields being recreated when content around them changes (e.g. new validation errors being displayed), which makes them lose focus. - Form and FormSet
cleanedData
is now always defined regardless of whether or not any validation has been performed yet - this makes it safe to check for data at any time, particularly in cross-field validation. - โก๏ธ Updated to React 0.10 - there are no library dependencies on new 0.10 features, but unit tests now make use of its enhanced support for rendering to static HTML.
๐ Bug Fixes
- FormSet sub-forms are no longer created from scratch every time they're accessed when running in the browser - this was throwing away form state, which effectively broke FormSets.
- ๐ Renamed