lib/api/model.js
function form (req, modelName, callback, formDsl) {

    const formFn = () => new Promise((resolve, reject) => {

        const formLabels = labels(modelName);
        const schema = get(modelName, true).schema;

        if (formDsl && typeof formDsl === 'function') {
            return resolve(pluginHelpers.formSettings(req, schema, clone(formDsl()), formLabels));
        }

        if (formDsl) {
            return resolve(pluginHelpers.formSettings(req, schema, clone(formDsl), formLabels));
        }

        // Get the form
        get(modelName, true).getForm(req, (err, decoratedForm) => {

            if (err) {
                return reject(err);
            }

            return resolve(decoratedForm);

        });

    });

    formFn()
        .then((result) => callback(null, result))
        .catch(callback);

}
function form (req, modelName, callback, formDsl) {

    const formFn = () => new Promise((resolve, reject) => {

        const formLabels = labels(modelName);
        const schema = get(modelName, true).schema;

        if (formDsl && typeof formDsl === 'function') {
            return resolve(pluginHelpers.formSettings(req, schema, clone(formDsl()), formLabels));
        }

        if (formDsl) {
            return resolve(pluginHelpers.formSettings(req, schema, clone(formDsl), formLabels));
        }

        // Get the form
        get(modelName, true).getForm(req, (err, decoratedForm) => {

            if (err) {
                return reject(err);
            }

            return resolve(decoratedForm);

        });

    });

    formFn()
        .then((result) => callback(null, result))
        .catch(callback);

}
function form ( req , modelName , callback , formDsl ) { const formFn = ( ) => new Promise ( ( resolve , reject ) => { const formLabels = labels ( modelName ) ; const schema = get ( modelName , true ) . schema ; if ( formDsl && typeof formDsl === 'function' ) { return resolve ( pluginHelpers . formSettings ( req , schema , clone ( formDsl ( ) ) , formLabels ) ) ; } if ( formDsl ) { return resolve ( pluginHelpers . formSettings ( req , schema , clone ( formDsl ) , formLabels ) ) ; } // Get the form get ( modelName , true ) . getForm ( req , ( err , decoratedForm ) => { if ( err ) { return reject ( err ) ; } return resolve ( decoratedForm ) ; } ) ; } ) ; formFn ( ) . then ( ( result ) => callback ( null , result ) ) . catch ( callback ) ; }
Retrieve the form DSL for a model
@param  {Object}   req       A HTTP request object which can be used to customised the form
@param  {String}   modelName The name of the model
@param  {Function} callback  A callback to return the form DSL to
@return {Void}
Retrieve the form DSL for a model