apostrophe-forms
Advanced tools
Comparing version 0.5.15 to 0.5.16
110
index.js
@@ -25,4 +25,42 @@ /* jshint node:true */ | ||
'slideshow', 'video' | ||
]; | ||
].concat(options.addControls || []); | ||
if (options.removeControls) { | ||
options.controls = _.filter(options.controls, function(field) { | ||
return !_.contains(options.removeControl, field); | ||
}); | ||
} | ||
options.addFields = [ | ||
{ | ||
name: 'body', | ||
label: 'Form Content', | ||
type: 'area', | ||
options: { | ||
controls: options.controls | ||
} | ||
}, | ||
{ | ||
name: 'submitLabel', | ||
label: 'Label for Submit Button', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'thankYouLabel', | ||
label: 'Thank You Message (title)', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'thankYouBody', | ||
label: 'Thank You Message (body)', | ||
type: 'string', | ||
textarea: true | ||
}, | ||
{ | ||
name: 'email', | ||
label: 'Email Results To', | ||
type: 'string' | ||
} | ||
].concat(options.addFields || []); | ||
_.defaults(options, { | ||
@@ -37,33 +75,3 @@ name: 'forms', | ||
], | ||
addFields: [ | ||
{ | ||
name: 'body', | ||
label: 'Form Content', | ||
type: 'area', | ||
options: { | ||
controls: options.controls | ||
} | ||
}, | ||
{ | ||
name: 'submitLabel', | ||
label: 'Label for Submit Button', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'thankYouLabel', | ||
label: 'Thank You Message (title)', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'thankYouBody', | ||
label: 'Thank You Message (body)', | ||
type: 'string', | ||
textarea: true | ||
}, | ||
{ | ||
name: 'email', | ||
label: 'Email Results To', | ||
type: 'string' | ||
} | ||
] | ||
addFields: options.addFields | ||
}); | ||
@@ -98,4 +106,10 @@ | ||
} | ||
]; | ||
] | ||
} | ||
if (options.removeGroups) { | ||
options.groupFields = _.filter(options.groupFields, function(field) { | ||
return !_.contains(options.removeGroups, field.name); | ||
}); | ||
} | ||
options.groupFields = options.groupFields.concat(options.addGroups || []); | ||
@@ -165,3 +179,3 @@ options.modules = (options.modules || []).concat([ { dir: __dirname, name: 'forms' } ]); | ||
name: 'required', | ||
label: 'Required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
@@ -184,3 +198,3 @@ } | ||
name: 'required', | ||
label: 'Required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
@@ -203,3 +217,3 @@ } | ||
name: 'required', | ||
label: 'Required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
@@ -222,3 +236,3 @@ } | ||
name: 'required', | ||
label: 'Required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
@@ -260,3 +274,3 @@ }, | ||
name: 'required', | ||
label: 'Must Check to Complete Form', | ||
label: 'Must Check to Complete Form?', | ||
type: 'boolean' | ||
@@ -312,2 +326,7 @@ } | ||
required: true | ||
}, | ||
{ | ||
name: 'required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
} | ||
@@ -326,2 +345,7 @@ ] | ||
required: true | ||
}, | ||
{ | ||
name: 'required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
} | ||
@@ -333,2 +357,12 @@ ] | ||
//add help text to schema if specified | ||
if(options.helpText){ | ||
_.each(options.widgets, function(options) { | ||
var helpText = { name: 'help', label: 'Help Text (optional)', type: 'string' }; | ||
if(options.name != 'sectionBreak'){ | ||
options.schema.push(helpText); | ||
} | ||
}); | ||
} | ||
// widgetEditors.html will spit out a frontend DOM template for editing | ||
@@ -335,0 +369,0 @@ // each widget type we register |
@@ -134,17 +134,3 @@ /* | ||
var values = parseChunk(chunk)._result; | ||
var row = ""; | ||
_.each(values, function(value, index) { | ||
if (index){ //add leading comma | ||
row +=","; | ||
} | ||
if (_.isArray(value) && value.length){ | ||
row += '"' + value.toString() + '"'; | ||
} else { | ||
row += value.toString(); | ||
} | ||
}); | ||
stringifier.write(row + '\n'); | ||
stringifier.write(values); | ||
}); | ||
@@ -151,0 +137,0 @@ |
{ | ||
"name": "apostrophe-forms", | ||
"version": "0.5.15", | ||
"version": "0.5.16", | ||
"description": "Allow your users to build forms on the fly on their Apostrophe sites", | ||
@@ -21,3 +21,5 @@ "main": "index.js", | ||
], | ||
"author": "P'unk Avenue LLC", | ||
"author": { | ||
"name": "P'unk Avenue LLC" | ||
}, | ||
"license": "MIT", | ||
@@ -35,3 +37,77 @@ "bugs": { | ||
"moment": "^2.10.6" | ||
} | ||
}, | ||
"gitHead": "865ccc20ecb0130d9952654113f0a1231ad82326", | ||
"_id": "apostrophe-forms@0.5.10", | ||
"_shasum": "d63727db7844c6ff1a821751e9953df6e5bdb6fc", | ||
"_from": "apostrophe-forms@*", | ||
"_npmVersion": "2.3.0", | ||
"_nodeVersion": "0.10.36", | ||
"_npmUser": { | ||
"name": "suhmantha1", | ||
"email": "sam@punkave.com" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "alexgilbert", | ||
"email": "alex@punkave.com" | ||
}, | ||
{ | ||
"name": "benirose", | ||
"email": "ben@punkave.com" | ||
}, | ||
{ | ||
"name": "boutell", | ||
"email": "boutell@boutell.com" | ||
}, | ||
{ | ||
"name": "colpanik", | ||
"email": "kerry@punkave.com" | ||
}, | ||
{ | ||
"name": "dkh202", | ||
"email": "danielkhunter@gmail.com" | ||
}, | ||
{ | ||
"name": "jimmyh", | ||
"email": "jimmy@punkave.com" | ||
}, | ||
{ | ||
"name": "joshuatrii", | ||
"email": "jan@joshuatrii.com" | ||
}, | ||
{ | ||
"name": "jsumnersmith", | ||
"email": "joel@punkave.com" | ||
}, | ||
{ | ||
"name": "kyjoya", | ||
"email": "kyleejacker@gmail.com" | ||
}, | ||
{ | ||
"name": "kylestetz", | ||
"email": "kylestetz@gmail.com" | ||
}, | ||
{ | ||
"name": "livhaas", | ||
"email": "olivia@punkave.com" | ||
}, | ||
{ | ||
"name": "mcoppola", | ||
"email": "coppola@punkave.com" | ||
}, | ||
{ | ||
"name": "stuartromanek", | ||
"email": "stuart@punkave.com" | ||
}, | ||
{ | ||
"name": "suhmantha1", | ||
"email": "sam@punkave.com" | ||
} | ||
], | ||
"dist": { | ||
"shasum": "d63727db7844c6ff1a821751e9953df6e5bdb6fc", | ||
"tarball": "http://registry.npmjs.org/apostrophe-forms/-/apostrophe-forms-0.5.10.tgz" | ||
}, | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/apostrophe-forms/-/apostrophe-forms-0.5.10.tgz" | ||
} |
101
README.md
@@ -48,2 +48,12 @@ A form builder for the [Apostrophe CMS](http://apostrophenow.org). | ||
To `add or remove controls` without overriding the entire option, use the addControls and removeControls configuration: | ||
```javascript | ||
'apostrophe-forms': { | ||
removeControls: ['video'], | ||
addControls: ['customWidgetType'] | ||
} | ||
``` | ||
## Adding New Widget Types & Validation | ||
@@ -127,2 +137,93 @@ | ||
## Adding custom fields | ||
Add or remove fields at the project level by passing in objects to the `addFields` or `removeFields` options array. | ||
```javascript | ||
'apostrophe-forms': { | ||
addFields: [ | ||
{ | ||
name: 'projectField', | ||
label: 'Project Level Field', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'thankYouLabel', | ||
label: 'Project-level Thank you Message', | ||
type: 'string' | ||
}, | ||
], | ||
removeFields: ['thankYouBody'] | ||
} | ||
``` | ||
Passing in a default field to the `addFields` array, such as `thankYouLabel` will override it at the project level. | ||
## Adding helper text to widget field schemas | ||
By default, there is no `helpText` schema in each widget field. By configuring help text in app.js: | ||
```javascript | ||
'apostrophe-forms': { | ||
helpText: true | ||
} | ||
``` | ||
Every widget schema now has an optional help field added to it. For instance, the default textField schema now looks like: | ||
```javascript | ||
{ | ||
name: 'textField', | ||
label: 'Text Field', | ||
css: 'apostrophe-text-field', | ||
schema: [ | ||
{ | ||
name: 'label', | ||
label: 'Label', | ||
type: 'string', | ||
required: true | ||
}, | ||
{ | ||
name: 'required', | ||
label: 'Required for User Submission', | ||
type: 'boolean' | ||
}, | ||
{ | ||
name: 'help', | ||
label: 'Help Text (optional)', | ||
type: 'string' | ||
} | ||
] | ||
} | ||
``` | ||
## Adding custom group fields | ||
There are three default field groups: `basicsTab, contentTab, thanksTab`. Add custom custom groups by setting the `addGroups` option in app.js: | ||
```javascript | ||
'apostrophe-forms': { | ||
addGroups: [ | ||
{ | ||
name: 'projectTab', | ||
label: 'Project Content', | ||
fields: [ | ||
'projectField' | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
To remove or override the default group fields use the `removeGroups` configuration: | ||
```javascript | ||
'apostrophe-forms': { | ||
removeGroups: ['contentTab'] | ||
} | ||
``` | ||
## What happens when forms are submitted | ||
@@ -129,0 +230,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
69811
1058
242
0