Vulcan/packages/nova-forms
2016-04-07 15:24:38 +09:00
..
lib refactor + simplify nova:forms logic 2016-04-07 15:24:38 +09:00
package.js include forms package in repo; add cache for FR-SSR; fix modal window callback issue; fix posts.single publication and subscription bug 2016-03-30 19:08:06 +09:00
README.md refactor + simplify nova:forms logic 2016-04-07 15:24:38 +09:00

React Forms

This package provides a NovaForm component that works with the schema extension defined in the smart-methods package to let you easily generate new document and edit document forms.

Install

meteor add nova:forms

Props

collection

The collection in which to edit or insert a document.

document

If present, the document to edit. If not present, the form will be a “new document” form.

currentUser

The current user.

submitCallback()

A callback called on form submission.

successCallback(document)

A callback called on method success.

errorCallback(document, error)

A callback called on method failure.

methodName

The name of the Meteor method to call.

labelFunction

A function to call on field names to get the label.

prefilledProps

A set of props to prefill for new documents.

Collection Schema

This package generates forms based on the following special schema properties (see also the Smart Methods package:

insertableIf(user)

A function called on the user performing the operation, should return true or false. When generating a form for inserting new documents, the form will contain all the fields that return true for the current user.

editableIf(user, document)

Called on the user performing the operation, and the document being operated on, and should return true or false. When generating a form for editing existing documents, the form will contain all the fields that return true for the current user.

control

Either a text string (one of text, textarea, checkbox, checkboxgroup, radiogroup, or select) or a React component.

order

A number corresponding to the position of the property's field inside the form.

Context

The main NovaForm components makes the following objects available as context to all its children:

prefilledValues

An object containing optional prefilled properties.

addToPrefilledValues({name: value})

A function that takes a property, and adds it to the prefilledValues object.

throwError({content, type})

A callback function that can be used to throw an error.