0.13.2 / 2015-10-26
October 26, 2015 ยท View on GitHub
Breaking Changes
- Now depends on React 0.14.
Changes
SelectandSelectMultipleno longer renderselectedattributes on their options, which was causing a warning message. React 0.14 now handles creating these in server-generated markup via parent context.- Documented that when using a custom rendering component with
RenderForm, the Form instance is now available via aformcontext variable due to React 0.14 parent context.
0.12.1 / 2015-03-12
Bug Fixes
-
Changed method of detecting if we're running in the browser to avoid false positives when browserify/webpack insert
processshims into browser bundles.A false positive can result in an
Errorbeing thrown when validating a client-sideFormSet(#75)
0.12.0 / 2015-03-11
Breaking Changes
- Now depends on React 0.13.
Changes
RenderFormno longer depends on havingReact.addons.cloneWithProps()available for custom rendering, due to newReact.cloneElement()top-level API.
Removals
- Removed deprecated
formsetFactory().
0.11.0 / 2015-03-11
Breaking Changes
- Renamed
BaseFormtoForm, changing the top-level API - this has the same behaviour as the currently-exportedforms.Form. - Renamed
BaseFormSettoFormSet, 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 as
Form,FormSet, fields, widgets, React components,ValidationError...) can be required withrequire('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
Fieldargument:field.widgetAttrs- this allows you to provide additional widget attributes without having to redefine the entire widget (#62) - Added
Form.prototype.prefixFormat('{prefix}-{name}') andFormSet.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 (#70)
Changes
- Added former
formsetFactory()options toFormSetproper.FormSetcan now be costructed directly, setting all formset-specific options instead of having to extend it.FormSet.extend()can now be used directly to preconfigure aFormSetconstructor with theFormconstructor to be used and any other formset options.
FormSetoptions can now be overridden when constructing aFormSet.- An error will now be thrown if a
FormSetis constructed without aFormconstructor. FileFieldcleaned data is now a nativeFileobject, when the browser supports it (#61)- Added a
multipleargument forFileField- cleaned data will be a list ofFileobjects. - Filename length and empty file validation can now be performed on the client
when a
Fileobject 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 extend
NumberInputto make use of them (#59)
Bug Fixes
DecimalFieldnow handles all-zero inputs correctly - it was cleaning them to an empty string (#57)Selectwidgets 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
Formrendering methods (render(),asTable(),asDiv()andasUl()). - Removed deprecated
FormSetrendering methods (render(),asTable()andasDiv()).
0.10.1 / 2015-01-08
- Version bump to fix tags -> keywords in package.json.
0.10.0 / 2015-01-04
Breaking Changes
- Removed
formset.asUl()- it never appeared properly due to the management Form. formset.cleanedData()to no longer includescleanedDatafrom incomplete extra forms.- You can no longer change
cleanedDataby returning a value from a Form'sclean<Name>()orclean()method.
New Features
- Added
RenderForm,FormRowandRenderFormSetcomponents for default rendering.- The browser build requires the react-with-addons build of React in order to
use
RenderForm's custom rendering support.
- The browser build requires the react-with-addons build of React in order to
use
- Custom
clean()andclean<Field>()validation methods can now be specified with the signature(callback)if they need to perform asynchronous validation.- The callback is an errback with the signature
(err, validationError). clean()will not be called until other fields - or just fields it depends on, if configured - have been cleaned, synchronously or asynchronously.
- The callback is an errback with the signature
form.validate()andformset.validate()now take a callback argument, which is required if the Form or Formset has custom async validation configured -validate()can be used as normal for Form and Formsets without async validation.- The callback is an errback with the signature
(err, isValid, cleanedData).
- The callback is an errback with the signature
- New API related to async validation:
form.isAsync()/formset.isAsync()-trueif a form/formset has custom async validation.form.isPending()/formset.isPending()-trueif a form/formset has pending async validation.form.nonFieldPending()/formset.nonFieldPending()-trueif async validation of a form/formset'sclean(cb)method is pending.boundField.isPending()-trueif a field has a pending async validation.isFormAsync(Form)-trueif a Form constructor's prototype has async validation methods.
<progress>indicators are now displayed by default rendering methods:- Beside fields with pending async validation.
- At the end of the form when cross-field validation is pending.
- Added more conditional CSS classes which will be used if defined in a Form:
optionalCssClass- used for optional fieldspendingCssClass- used for fields with pending async validation
- Added
boundField.helpTextTag()to expose the mechanism for rendering raw HTML. - Added
boundField.status()to get a field's status as a string (pending/error/valid/default). - Added
fromJSON()factory functions toErrorListandErrorObjectconstructors andfromJSON()instance methods. These can be used to rehydrate anErrorObjecton the receiving end whenform.errors()is transferred as JSON. This assumes the structure created by these objects'toJSON()methods. - Added
form.setErrors()to set anErrorObjectwith errors from another source. - An
ErrorObjectcan now be passed as anerrorsoption when creating a form instance, to redisplay a form with errors from another source. This prevents the form's own validation from running if the form has inputdataandisValid()orerrors()are called during rendering.
Deprecations
- Form rendering methods (
render(),asTable(),asDiv()andasUl()) are deprecated in favour of using React components for rendering -RenderFormnow provides default rendering. - FormSet rendering methods (
render(),asTable()andasDiv()) are deprecated in favour of using React components for rendering -RenderFormSetnow provides default rendering.
Changes
- Reverted a change from 0.9. Synchronous calls to
form/formset.validate()will trigger a re-render, as it looks likeforceUpdate()just enqueues a future re-render. form.isComplete()is nowfalseif there is any pending async validation, even if all required fields currently have cleaned data.- Changes to when event-based validation fires:
- Validation now only fires if the field's data has changed since it was last
validated. For
'auto'validation, this prevents the defaultonBlurevent from re-running the same validation as the defaultonChange. - Special cases for
onBlur:- Pending validation is triggered immediately.
- Validation is always triggered if the field is required and empty.
- Validation now only fires if the field's data has changed since it was last
validated. For
- Changed
form.addError()to no longer add duplicate error messages for the same field. This can happen ifonChangevalidation which runs repeatedly adds errors to a field other than that which triggered the validation, usingaddError(). - The default
rowsattribute for aTextareachanged from 10 to 3. - Error messages now make use of a
displayNameproperty if a Form has one.
Removals
- The deprecated
onStateChangeargument to Form and FormSet constructors has been removed - useonChangeinstead.
0.9.1 / 2014-11-25
- The object given to
Form.extend()is no longer mutated.
0.9.0 / 2014-11-11
Breaking Changes
- Form mixins must now be specified as a
__mixins__property rather than__mixin__. - Changed
form.validate()to no longer call back to re-render - this was convenient for single forms, but results in multiple updates when processing multiple forms. Re-rendering must now be triggered manually if onSubmit validation fails. formset.cleanedData()to no longer includescleanedDatafrom unmodified extra forms.
New Features
- Passing
onChangeto a Form or FormSet now impliesvalidation: 'auto'. - Added
form.notEmpty()to determine when required fields in an extra FormSet form become truly required. - Added
formset.validate([form])- equivalent to the Form version, use to set a formset's data from a<form>or to force full validation of its current input data. - Added
formset.removeForm(index)to remove extra forms from a FormSet. It will also call back to trigger a re-render when possible. - Added
errorlist#first()for conveniently getting just the first validation error message. - Added
formset.addError()for adding non-form errors outside ofclean(). - Changed
form.validate([form])so the argument is optional - it can now be used to force full validation of a form with its current input data. - Form
clean()functions can now specify which fields they make use of for cross-field validation:clean: ['field1', 'field2', function() {}]. When provided,clean()will only be called during partial form updates (e.g.onChangehandling) if one of the specified fields is affected.
Deprecations
- The
onStateChangeargument to Form and FormSet constructors - useonChangeinstead.onStateChangewill be removed in the next version.
Changes
onChangehandlers are now always attached to widgets to update input data, regardless of controlled/validation config.formset.addAnother()will now call back to trigger a re-render if possible.- Changed partial form validation to remove any validation errors if an extra FormSet form is unchanged from its initial values.
0.8.0 / 2014-10-29
- Updated to React 0.12 - using new
React.createElement()andReact.createFactory()API forReactElementcreation.
0.7.0 / 2014-07-27
- Updated to React 0.11 - there are no library dependencies on new 0.11 features, but unit tests depend on improvements made to its static HTML generation.
New Features
- Added locale support.
0.6.0 / 2014-05-07
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 newsetFormData()method which replicates the old behaviour. This makessetData()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
validationoption when constructing a Form, Field or FormSet. - Added toggling of creation of controlled React components, configured by
passing a
controlledoption 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 usingBoundField#cssClasses()directly, if present on a form or its prototype. - Added a top-level
validateAllutility method equivalent toform.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.
0.5.2 / 2014-04-03
- Fixed Select widget's defaultValue attribute.
0.5.1 / 2014-04-01
- Fixed browserification when used as a Node module.
0.5.0 / 2014-03-11
Changes in addition to 0.5.0-rc1:
-
Made hidden fields controlled components which always reflect form state on each render, since there's no way for the user to interact with them.
-
Made FormSets more usable on the client-side:
- Form instances aren't cached, so adding and removing forms by tweaking form count variables works without having to recreate the formset, or touching undocumented state.
- ManagementForm isn't used for formset configuration details when the formset is bound - as a result, you don't have to render its hidden fields for browser-only usage.
- If rendered, the ManagementForm always reflects FormSet state, not bound
data, so doing things like bumping
formset.extrato show another form works regardless of whether or not the formset is bound. - Added a
setData()method to bind newformset.dataand re-trigger validation.
0.5.0-rc1 / 2014-03-08
Breaking Changes
-
Now depends on React 0.9.0.
-
Newforms components now render by creating
React.DOMcomponents instead of relying on context-specific output fromDOMBuilder.createElement(). -
Components which can be rendered no longer have
toString()methods -- creation of final output is now handled by callingReact.renderComponentorReact.renderComponentToStringon a React component which includes rendered output of a newforms Form - this (temporarily) breaks usage of newforms in String-based templating libraries such as Jade. -
HTML output has changed - this will break any tests which depended on the specifics of how DOMBuilder generated HTML.
- React has no equivalent of a virtual DocumentFragment as yet - there are new wrapper elements in various places.
- React wraps free-standing text nodes with
<span>. - Boolean attributes no longer have a value duplicating the attribute name.
-
HTML attribute names must now match what React expects - no more
'maxlength'or quoted'class'and'for'attributes. -
A String can no longer be used to specify multiple selected items in a
SelectMultiple- this used to be an accident based on duck typing of index access to both items in an Array and characters in a String. If a non-Array is given as the selected value, it will now be wtapped in an Array. -
CheckboxInputno longer silenty swallows any errors thrown by the providedcheckTestfunction. -
_hasChangedhas moved from Widgets to Fields. -
The default error message for an invalid email address has changed.
-
ValidationErrorAPI changed -messagesis now a function rather than an array of Strings. -
ErrorListAPI changed - amessages()method must now be called to get final error message strings out of it. -
Replaced
asP()withasDiv(), as invalid markup nesting breaks React when browsers perform error correction on the DOM. -
Renamed
Field.extraCLassesoption toField.cssClass. -
Renamed
asUL()methods toasUl(). -
Order of mixing in fields from when multiple Forms are passed to
__mixin__has changed from right-to-left to left-to-right. -
Only one custom field cleaning functon will be called:
clean<FieldName>orclean_<fieldName>in that order. The ability to define both and have both run was unintentional.
New Features
-
A
typeattribute can now be passed to Widgets to take advantage of new HTML widget types.-
Added
EmailInput- now the default widget forEmailField -
Added
URLInput- now the default widget forURLField -
Added
NumberInput- now the default widget forIntegerField,FloatFieldandDecimalFieldIntegerField,FloatFieldandDecimalFieldnow set HTML5max,minandsteoattributes on their widget, as applicable.
-
-
formDatanow supports new input types: 'email', 'url', 'number' and 'file' -
If a field throws a
ValidationErrorwhile checking if it's changed, the assumption is now that it's changed. -
cleanedDatais no longer deleted when a form is invalid. -
CheckboxSelectMultiplenow uses a similar renderer toRadioSelect-- individual checkbox subwidgets can now be accessed. -
idattributes are now added to lists of radio and checkbox inputs. -
Radio and checkbox input lists can now display with nested choices
-
SlugFieldandURLFieldnow support whitespace stripping. -
Changed data checking now supports calling initial values which are functions.
-
Added
minNum,validateMaxandvalidateMintoformsetFactoryandBaseFormSet. -
Added a hard limit to the maximum number of forms in a
FormSet-maxNum- 1000.
-
FormSet deletion management data is no longer removd from
cleanedData. -
MultiWidgetnow setsneedsMultipartFormbased on its child widgets. -
Added
requireAllfieldsoption toMultiValueField- this allows for optional subfields whenfalseand a new'incomplete'validation error being thrown when required field are empty. -
Added an
addError()method to forms which can be used to set field or non-field errors and automatically removes fields fromcleanedData, -
cleanedDatadoesn't need to be returned fromForm.clean()any more, but if it is, it will still be set asform.cleanedData. -
Made
emptyValuesa property ofField.prototypeso it can be overridden by subclasses if necessary. -
TypedChoiceField#coercecan now return an arbitrary value. -
labelSuffixcan now be customised when callingBoundField#labelTag. -
validators is now exposed as
forms.validators. -
Added
Field#isEmptyValueandField#emptyValueArrayto ensure empty arrays are detected as empty values by default. -
Added the ability to avoid inheriting a field from an extended or mixed-in Form by shadowing its field name with a non-field property.
-
Added
asData()andtoJSON()toErrorObjectandErrorList. -
Custom
clean<FieldName>()methods no longer have to return a cleaned value, but if they do, it will be inserted back intocleanedData. -
ClearableFileInputnow uses overridable functions for templating, making it easier to customise. -
FileFieldnow validates that a file is selected whenrequiredistruein browsers. -
Default rendering methods now allow arbitrary HTML in
helpTextif{__html: ''}is passed instead of a string. -
Added
form.setData()to bind new data to a form and re-trigger cleaning. -
Added a
customargument when constructing Fields, to store any metadata you need for later. -
ImageFieldnow adds anaccept="image/*"attribute to its widget. -
Added
form.util.makeChoiceshelper for creating [value, label] pairs from a list of objects. -
Flat lists of
choicescan now be passed into Fields and Widgets which take choices.
Bug Fixes
'0'should be treated as true byCheckboxInput.CheckboxInput._hasChangednow handles an initial'false'String.FloatFieldandDecimalFieldnow accept '1.' as a valid input.- Fixed form constructors used as mixin mixins having their own
baseFieldsoverwritten and the prototype properties intended for the new form applied to them. - Fixed
Boundfield#subWidgetsnot passingidorautoIdalong, so label htmlFors and input ids weren't getting generated.
0.4.2 / 2012-07-15
- Automatically-added deletion fields are no longer included in the list of cleanedData for a FormSet [whardeman]
- Data for forms marked for deletion is no longer present in a FormSet's cleanedData [whardeman]
- Fixed
FloatField.prototype._hasChanged(), which wasn't comparing against the field's initial value - Added
managementFormCssClassto BaseFormSet's kwargs, to provide a CSS class for the row generated to hold the management form's hidden fields - Added use of
hiddenFieldRowCssClassto provide a CSS class for Form rows which were generated solely to wrap empty fields to avoid generating invalid HTML - Added use of
rowCssClassto provide a class for each row in a Form [whardeman]
0.4.1 / 2012-06-29
- Updated to isomorph 0.2
- Added
extraClassesto Field's kwargs [whardeman]
0.4.0 / 2012-03-08
- Extracted validators into a validators
project and added it as a dependency - as a result,
callValidator(),isCallable()and IPv6 functions now live underforms.validators - Extracted URL utility functions out into isomorph
- Fixed #11: a validator's error message should take precedence unless the field it's validating has defined a custom error message using the same error code
- Changed
BoundField.protoype.labelTag()to also include the form'slabelSuffix
0.3.0 / 2012-02-10
- Added GenericIPAddressField
- Renamed
forms.validateIPV4Addresstoforms.validateIPv4Addressfor consistency with new IPv6 validation - Added SubWidgets to allow you to iterate over invdidiual elements which make up a widget - currently only used by RadioSelect
- Changed MultiValueField to run any validators it was given
- Changed URL and email address validators to handle IDNA domains
- Changed CheckboxInput to correctly handle
0as a value - Added
BaseFormSet.prototype.hasChanged() - Changed Select widget to only allow for one selected option with the same value
0.2.0 / 2012-02-05
- Backwards-incompatible change to
forms.Form- this used to be a factory function, but is now a constructor created with Concur which, when extended from, will move given Field properties into the new constructor'sbaseFieldsprototype property - Backwards-incompatible change: renamed
forms.FormSettoforms.formsetFactoryso it's named like the factory function it is, rather than like a constructor
0.1.1 / 2012-02-01
- Fixed browser build - IE7/8 object.hasOwn incompatibility fixed in isomorph.
0.1.0 / 2012-01-31
- Changed code structure - now written as regular Node.js modules
- Changed API for placeholder strings, which are now
'{placeholder}'style instead of'%(placeholder)s' - Changed
forms.utilAPI, as most utility methods have been split out into ispmorph, which is now a dependency - Added extension sugar via Concur - all
newforms constructors now have an
extend()function