v0.11.0
See the Upgrade Guide for instructions on upgrading to this release from the previous version.
Breaking Changes
- Renamed
BaseForm
toForm
, changing the top-level API - this has the same
behaviour as the currently-exportedforms.Form
. - Renamed
BaseFormSet
toFormSet
, changing the top-level API. - Replaced
util.formData()
with the
get-form-data module -
formData()
has been renamed togetFormData()
. - Newforms is now published to npm as flattened, top-level modules, so
individual modules (such asForm
,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 toFormSet
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 aFormSet
constructor with theForm
constructor to be used and any other formset
options.
FormSet
options can now be overridden when constructing aFormSet
.- An error will now be thrown if a
FormSet
is constructed without aForm
constructor. FileField
cleaned data is now a nativeFile
object, when the browser
supports it (docs) (#61)- Added a
multiple
argument forFileField
- cleaned data will be a list of
File
objects. - Filename length and empty file validation can now be performed on the client
when aFile
object is available.
- Added a
- 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 extendNumberInput
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 usingFormSet.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()
andasUl()
). - Removed deprecated
FormSet
rendering methods (render()
,asTable()
and
asDiv()
).