Skip to content

v0.6.0 - Interactive Forms

Compare
Choose a tag to compare
@insin insin released this 07 May 19:38
· 278 commits to react since this release

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.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.