Skip to content

v0.11.0

Compare
Choose a tag to compare
@insin insin released this 11 Mar 04:14
· 29 commits to react since this release

See the Upgrade Guide for instructions on upgrading to this release from the previous version.

Breaking Changes

  • Renamed BaseForm to Form, changing the top-level API - this has the same
    behaviour as the currently-exported forms.Form.
  • Renamed BaseFormSet to FormSet, changing the top-level API.
  • Replaced util.formData() with the
    get-form-data module -
    formData() has been renamed to getFormData().
  • Newforms is now published to npm as flattened, top-level modules, so
    individual modules (such as Form, FormSet, fields, widgets, React
    components, ValidationError...) can be required with
    require('newforms/<modulename>') - this makes it possible to reduce the size
    of your own browser bundles by requiring only what you use.

New Features

  • Added new core Field argument: field.widgetAttrs - this allows you to
    provide additional widget attributes without having to redefine the entire
    widget (docs) (#62)
  • Added Form.prototype.prefixFormat ('{prefix}-{name}') and
    FormSet.prototype.prefixFormat ('{prefix}-{index}') to define how prefixes
    are generated. These can be overridden when extending these components to
    customise now field names are generated when prefixes are used
    (example) (#70)

Changes

  • Added former formsetFactory() options to FormSet proper (API docs)
    • FormSet can now be constructed directly, setting all formset-specific options for the instance instead of having to extend it,
    • FormSet.extend() can now be used directly to preconfigure a FormSet
      constructor with the Form constructor to be used and any other formset
      options.
  • FormSet options can now be overridden when constructing a FormSet.
  • An error will now be thrown if a FormSet is constructed without a Form
    constructor.
  • FileField cleaned data is now a native File object, when the browser
    supports it (docs) (#61)
    • Added a multiple argument for FileField - cleaned data will be a list of
      File objects.
    • Filename length and empty file validation can now be performed on the client
      when a File object is available.
  • Widget attribute defaults are now always provided by numeric fields when not
    already set, regardless of the type of widget being used, to allow custom
    widgets which don't extend NumberInput to make use of them
    (#59)

Bug Fixes

  • DecimalField now handles all-zero inputs correctly - it was cleaning them
    to an empty string (#57)
  • Select widgets no longer generate React dev-mode warnings about unique key
    props (#68)

Deprecations

  • formsetFactory() is deprecated in favour of using FormSet.extend() to
    create a FormSet with defaults for the same options and any custom methods
    required.

Removals

  • Removed deprecated Form rendering methods (render(), asTable(), asDiv()
    and asUl()).
  • Removed deprecated FormSet rendering methods (render(), asTable() and
    asDiv()).