newforms v0.6.0 Release Notes

Release Date: 2014-05-07 // almost 10 years ago
  • ๐Ÿ’ฅ Breaking Changes

    • ๐Ÿ“‡ Renamed form.isBound to form.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 a prefixed option 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 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 of form.data, so you can change what's displayed in the form by updating its data.
    • โž• Added calling of aonStateChange() 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 using validation or controlled 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 to form.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-form onSubmit 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 using BoundField#cssClasses() directly, if present on a form or its prototype.
    • โž• Added a top-level validateAll utility method equivalent to form.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.