Releases: insin/newforms
Releases · insin/newforms
newforms 0.5.0 - first release as a React library
What's New?
newforms now renders by creating React DOM components instead of using DOMBuilder's environment-specific output - React is a much better fit for newforms on the client side as it takes care of keeping the DOM in sync with your generated forms, without having to blow the lot away every time you want to update.
The parts of newforms base functionality which are ported from Django should now be in line with what's on offer in the upcoming Django 1.7 release.
If you were previously using newforms with text-based templates such as Jade in Node,js, stck with v0.4.2 for now...
Breaking Changes
- Now depends on React 0.9.0.
- Newforms components now render by creating
React.DOM
components 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.renderComponent
orReact.renderComponentToString
on 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.
- React has no equivalent of a virtual DocumentFragment as yet - there are new
- 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. CheckboxInput
no longer silenty swallows any errors thrown by the provided
checkTest
function._hasChanged
has moved from Widgets to Fields.- The default error message for an invalid email address has changed.
ValidationError
API changed --messages
is now a function rather than
an array of Strings.ErrorList
API 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.extraCLasses
option 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
type
attribute 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
,
FloatField
andDecimalField
IntegerField
,FloatField
andDecimalField
now set HTML5max
,
min
andsteo
attributes on their widget, as applicable.
- Added
formData
now supports new input types: 'email', 'url', 'number' and 'file'- If a field throws a
ValidationError
while checking if it's changed, the
assumption is now that it's changed. cleanedData
is no longer deleted when a form is invalid.CheckboxSelectMultiple
now uses a similar renderer toRadioSelect
--
individual checkbox subwidgets can now be accessed.id
attributes are now added to lists of radio and checkbox inputs.- Radio and checkbox input lists can now display with nested choices
SlugField
andURLField
now support whitespace stripping.- Changed data checking now supports calling initial values which are functions.
- Added
minNum
,validateMax
andvalidateMin
toformsetFactory
and
BaseFormSet
. - Added a hard limit to the maximum number of forms in a
FormSet
--maxNum
-
- FormSet deletion management data is no longer removd from
cleanedData
. MultiWidget
now setsneedsMultipartForm
based on its child widgets.- Added
requireAllfields
option toMultiValueField
-- this allows for
optional subfields whenfalse
and 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
, cleanedData
doesn't need to be returned fromForm.clean()
any more,
but if it is, it will still be set asform.cleanedData
.- Made
emptyValues
a property ofField.prototype
so it can be overridden
by subclasses if necessary. TypedChoiceField#coerce
can now return an arbitrary value.labelSuffix
can now be customised when callingBoundField#labelTag
.validators
_ is now exposed asforms.validators
.- Added
Field#isEmptyValue
andField#emptyValueArray
to 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()
toErrorObject
andErrorList
. - Custom
clean<FieldName>()
methods no longer have to return a cleaned
value, but if they do, it will be inserted back intocleanedData
. ClearableFileInput
now uses overridable functions for templating, making
it easier to customise.FileField
now validates that a file is selected whenrequired
is
true
in browsers.- Default rendering methods now allow arbitrary HTML in
helpText
if
{__html: ''}
is passed instead of a string. - Added
form.setData()
to bind new data to a form and re-trigger cleaning. - Added a
custom
argument when constructing Fields, to store any metadata
you need for later. ImageField
now adds anaccept="image/*"
attribute to its widget.- Added
form.util.makeChoices
helper for creating [value, label] pairs from
a list of objects. - Flat lists of
choices
can now be passed into Fields and Widgets which take
choices. - 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 bumpingformset.extra
to show another form
works regardless of whether or not the formset is bound. - Added a
setData()
method to bind newformset.data
and re-trigger
validation.
- Form instances aren't cached, so adding and removing forms by tweaking form
Bug Fixes
'0'
should be treated as true byCheckboxInput
.CheckboxInput._hasChanged
now handles an initial'false'
String.FloatField
andDecimalField
now accept '1.' as a valid input.- Fixed form constructors used as mixin mixins having their own
baseFields
overwritten and the prototype properties intended for the new
form applied to them. - Fixed
Boundfield#subWidgets
not passingid
orautoId
along, so
label htmlFors and input ids weren't getting generated.