v0.6.0 - Interactive Forms
The main features for this release are the addition of interactive validation and toggleable creation of controlled components, documentation and examples here:
Breaking Changes
- Renamed
form.isBoundtoform.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 aprefixedoption argument which controls this and a new
setFormData()method which replicates the old behaviour. This makes
setData()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 avalidationoption when constructing a Form, Field or FormSet. - Added toggling of creation of controlled React components, configured by
passing acontrolledoption 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 usingvalidationorcontrolledoptions. - 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
validateoption 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-formonSubmitvalidation. - 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
validCssClassin default rendering or when using
BoundField#cssClasses()directly, if present on a form or its prototype. - Added a top-level
validateAllutility method equivalent to
form.validate()but for multiple Forms and/or FormSets. - Added
Widget.prototype.needsInitialValueto 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
keyproperty, 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
cleanedDatais 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.