【发布时间】:2016-06-21 21:48:46
【问题描述】:
Schemas = {};
Schemas.ContactForm = new SimpleSchema({
name: {
type: String,
label: "Your name",
max: 50
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email,
label: "E-mail address"
},
message: {
type: String,
label: "Message",
max: 1000
}
});
HTML:
<template name="contactForm">
{{#autoForm schema=Schemas.ContactForm id="contactForm" type="method" meteormethod="sendEmail"}}
<!-- etc. -->
{{/autoForm}}
</template>
流星法,请查看cmets:
Meteor.methods({
sendEmail: function(contents){
check(contents, Schemas.ContactForm);
Mandrill.messages.send({
// do something to send
}, function(error, response){
if (error){
// how does error bubble back up to the client?
} else {
// how does success bubble back up to the client?
}
})
},
})
所以使用 AutoForm meteormethod 属性,我如何从我的服务器调用 Mandrill 获得错误或响应以冒泡回客户端,以便我可以通知用户表单已成功提交并通过电子邮件发送?
不使用 AutoForm 上的 meteormethod 属性并在表单提交时手动连接 Meteor.call 会更好吗?
【问题讨论】:
标签: meteor mandrill meteor-autoform