我一直在按照Apostrophe CMS文档创建一个基本的联系表单,并且可以正常工作,但是现在我想使用apostrophe-pieces-submit-widgets模块删除“多余的”代码。我尝试在我的app.js文件中使用它并创建一个contact-form-submit-widgets模块,但收到以下错误:
未定义类型'撇号-提交-小部件'。
这是一个全新的空白项目,到目前为止,我添加的唯一代码是contact-form模块架构,如下所示:
const async = require('async');
module.exports = {
extend: 'apostrophe-pieces',
name: 'contact-form',
label: 'Contact Form',
alias: 'contactForm',
addFields: [
{
name: 'title',
type: 'string',
label: 'Full Name',
required: true
},
{
name: 'email',
type: 'string',
label: 'Email',
required: true
},
{
name: 'message',
type: 'string',
label: 'Message',
textarea: true,
required: true
}
],
permissionsFields: false,
construct: (self, options) => {
self.setSubmitSchema = () => {
self.submitSchema = self.apos.schemas.subset(self.schema, [
'title',
'email',
'message'
]);
};
self.submit = (request, callback) => {
const piece = {};
return async.series([
callback => self.apos.schemas.convert(request, self.schema, 'form', request.body, piece, callback),
callback => self.insert(request, piece, { permissions: false }, callback)
], callback);
};
},
afterConstruct: self => {
self.setSubmitSchema();
}
};
任何帮助将不胜感激。
韦恩