AutoForm is a smart package for Meteor that adds handlebars helpers to easily create basic forms with automatic insert and update events, and automatic reactive validation.
- API Change: boolean attributes on inputs are now passed through to the generated HTML only if the value is
true
or"true"
or""
. This is different from HTML in which boolean attributes take effect simply by being present. This change allows you to reactively add or remove a boolean attribute in a simple way, for example,{{> afQuickField name='status' disabled=canEditStatus}}
. You should review any boolean attributes you use on autoform fields to ensure that they have the correct value, or they may no longer show up in the HTML. - Fixed an issue where reactive lists of check box inputs would have incorrect check boxes selected after the list changed
- Removed
for
attribute from radio labels in the bootstrap3 template, since it should not be there; makes the labels correctly clickable - Completely rewrote behind-the-scenes array field tracking, fixing a number of issues with adding and removing array fields and correctly updating arrays
- Before hooks are now passed the template instance
formToDoc
anddocToForm
hooks are now passed the SimpleSchema instance and formid
, which is useful if you define them globally (passnull
for the first argument ofAutoForm.addHooks
)
- Support for limiting the number of items in an array field. See "afArrayField" section in the README.
- In the default templates, when you can't add or remove array items, the corresponding buttons are hidden.
- You can now specify fields that are in objects within arrays in the
omitFields
attribute on aquickForm
. For example,names.$.first
. (Thanks @picsoung!) - Clearing all check boxes for an optional array field will now properly unset the field.
- Other bug fixes (Thanks @jfols and @BasilPH)
- Disabled fields are no longer submitted or included in the generated insert or update object.
- Changes that prevent global helpers from potentially interfering with correct autoform generation. (Thanks @mjgallag)
- Fix contenteditable field. (Thanks @chrisbutler)
- Ensure that
template
attribute is not added to the DOM element for all components - Add
afFieldValueContains
, likeafFieldValueIs
but for checking whether an array field contains the value - Add reactive
AutoForm.getFieldValue
method, useful for creating helpers to support more advanced field filtering based on combinations of current field values - Add
bootstrap3-horizontal
built-in template - Documentation improvements:
afObjectField
andafArrayField
components are now documented, and added link to the autogenerated public API documentation
Remove unintentional console log
Minor fixes for afFieldValueIs
helper
Add afFieldValueIs
helper for dynamic show/hide of form sections based on the current value of any field.
Fix an issue where generated modifiers sometimes had the same field listed in both $set
and $unset
.
Improve some error messages
- Add
omitFields
attribute forquickForm
. Similar to thefields
attribute but for blacklisting instead of whitelisting.
Much thanks to @gdhuse for the following fixes and enhancements:
- Add option to replace hooks instead of extending the current list when calling
hooks
oraddHook
. - Allow insert/update forms without a
collection
attribute if there is at least oneonSubmit
hook and at least oneonSubmit
hook returnsfalse
. - Fix issue with array fields
- Fix issue with update modifiers created from autoform field values.
Fix issue with datetime fields
Minor fix
Blaze/0.8.0 support and lots more, including breaking changes. Refer to the transition notes at the top of the README. If you're still using Spark (pre-0.8.0), use the 0.4.x version. The old version of autoform can be found on the spark
branch. It won't receive any more changes, except for critical fixes. Onward!
Better implementation of defaultValue
support
- Use jQuery to fix issues related to maintaining selections in a cross-browser way. (Thanks @mjgallag)
- Use schema
defaultValue
as default value for boolean controls.
A couple more bug fixes related to cleaning objects.
Bug fix for validation of updates when auto values are involved. (Thanks @mjgallag)
Add support for contenteditable
input type. (Thanks @chrisbutler)
- Labels are now generated with "for" attribute
- QuickForms work better with schemas containing objects now. The object is
treated as a
fieldset
with its child fields nested within. This only works to one level deep. - The
updateDoc
passed to anonSubmit
handler is no longer validated before being passed. TheinsertDoc
is still validated. - Changes to account for
autoValue
anddefaultValue
options now available in the SimpleSchema package.
The execution flow for hooks has been improved. The onError
hook is now
always called if there's an error at any point in the form submission process,
and it will never be called more than once. Also, any "before" hooks are now
executed before the onSubmit
hook. (Thanks @blazer82)
Changes related to SimpleSchema package changes. No visible changes.
Add support for fields
attribute on quickForm
. Bind an array or specify
a comma-delimited string of field names to include. Only the listed fields
will be included, and they'll appear in the order you specify.
- Don't include fields in quickForms if their name contains "$"
- Use
textarea
instead ofinput[type=text]
if the schema type isString
, no specific type attribute is specified, and the current value of the doc contains line break characters. - Within an
onSubmit
function, you can now accessthis.event
andthis.template
. - Specify
element="none"
orelement="span"
on afFieldLabel to get just the text or to use a<span>
element, respectively. quickForm
andafQuickField
now support atemplate
attribute, allowing you to define your own template to be used for the quick fields.- Provide
resetOnSuccess
attribute to specify auto-reset behavior for a specific autoform.
Add explicit cleaning since SimpleSchema validation does not do it anymore
Fix error when a source doc has null values
Minor internal change to adjust for changes made to the internal schema in the SimpleSchema package.
- quickForm no longer displays fields for denyInsert or denyUpdate keys when building an insert or update form, respectively.
- Fix an issue with being able to pass a Collection2 as the autoForm schema. (This is not recommended anyway.)
- Automatically disable the submit button while submitting an autoform.
Ensure docToForm hook is called
Add onSuccess and onError hooks
- Fix issues, introduced by 0.4.3, where select, checkbox, and radio form values were not always correct.
- Throw errors in afFieldMessage and afFieldIsInvalid helpers when the field name used doesn't exist in the schema. (Other helpers already did this.)
- Add two new "type" options for quickForms: "readonly" and "disabled". See README.
- When displaying a quickForm, use the allowedValues from the schema as the options.
Update to use MongoObject to create flatDoc. Fixes an issue caused by recent SimpleSchema API changes.
- New API. The old API is deprecated but continues to work for now with warning
messages logged. See the README and warning messages. The main difference is
that the various hooks/callbacks are centralized in a
hooks()
method, but this is available only onAutoForm
instances, so you need to wrap yourCollection2
instance in anAutoForm
on the client and then attach hooks to the autoform, passing the autoform as theschema
attribute for yourautoForm
helper. Also, the server methods have all been removed, making this a purely client package. This means you should now define aSimpleSchema
in common code and use that to create anAutoForm
instance on the client only. This allows you to still validate against the sameSimpleSchema
on both the client and the server. See examples in the README. - You can now set
options
to the string "allowed" forafFieldInput
orafQuickField
. This causes the schema'sallowedValues
to be used as the values (and labels) for the select element. If you want to capitalize the first letter of the labels, setcapitalize="true"
. (Thanks @gdhuse!) - SimpleSchema error messages with HTML will now display correctly when you use
an
afQuickField
. (Thanks @gdhuse!)
Improve handling of key names that use dot notation to indicate a property of
an object in an array, for example, friends.0.name
.
Backwards-compatibility break! Handling of Date
fields was limited and saved
Date
objects were not correct. If you have previously saved Date
objects
from an autoform date
input, you will have to manually convert the saved values
to correct them after upgrading to this release. If it is only the date you care
about and not the time, all dates in your mongo collections must represent
midnight in the UTC time zone on the morning of the correct date. Refer to the
Dates section of the README
for details about how date inputs work now.
Support min/max functions
Add framework override support; current usage is only to specify "none" to skip the bootstrap3 classes
Fix object expansion
Improve object collapsing. Ensures that the values of keys with dot notation appear in the fields for edit forms.
Fix IE<10 errors
Fixes to date inputs
Updated to work with 0.2.0 versions of collection2 and simple-schema packages. The autoform features should be backwards-compatible, but the collection2 and simple-schema APIs have changed, so you may need to make changes. To make sure everything works as you expect, it's strongly recommended that you include a unique id
attribute on every autoForm
helper.
- Fix IE<10 issue
- Use
submit form
event handler instead of button click handlers - Add support for binding an
onSubmit
handler to an autoForm using theonSubmit
helper attribute. - Don't include
form-control
class on radio buttons and check boxes - Submit the form normally after validating if none of the special actions are used
Fix input helper to use value passed in value
attribute if no doc is attached to the autoform.
- For autoforms that call a server method, server-side validation is no longer performed automatically. This had to be removed to fix a security issue. After updating to 0.2.0, you must call
check()
in the Meteor method. - Add
formToDoc
anddocToForm
functions. See the readme. - Improve keyup validation
- Allow direct binding of Collection2 or AutoForm object to autoForm helper through the schema attribute. Passing in the string name of a global object is still supported, but binding is the preferred method now.