Skip to content

Scaffold

Daryl Hedley edited this page Feb 3, 2015 · 15 revisions

Description

Scaffold is used to build out all our main form editing pages. At the heart of it is Backbone Forms that enables us to use schemas to render forms with very little effort. Scaffold wraps around Backbone Forms and offers us an API that can enable fieldsets, custom views, custom fields, custom templates and custom validators. It also manages overlays opened during editing forms and pulls down new schemas when plugins are configured.

API

Origin.scaffold.buildForm(options)

This will build a form object that can be used to append and commit the Backbone Form object. To build a form:

var form = Origin.scaffold.buildForm({
    model: contentObjectModel
});

If you would like a different schemaType from the _type attribute you can pass in a schemaType attribute when building a form.

var form = Origin.scaffold.buildForm({
    model: contentObjectModel,
    schemaType: 'menuSchema'
});

Origin.scaffold.addCustomField(fieldName, view, overwrite)

To add a custom field pass in the fieldName and the view. This creates a custom view that whenever this field is present in a schema it will use this instead of a standard Backbone Form input. Passing in overwrite as a boolean will overwrite this custom view - this enables plugins to overwrite a core plugin custom view.

Origin.scaffold.addCustomField('Asset:image', ScaffoldAssetView);
Clone this wiki locally