我们能否获得流星初学者的完整联系表格示例?
到目前为止的步骤.
使用https://github.com/aldeed/meteor-autoform#an-example-contact-form上的信息进行操作
两者/收藏/ contact.coffee
@Contacts = new Meteor.Collection('contacts')
Schemas.Contacts = new SimpleSchema
name:
type: String
label: "Your name"
max: 50
optional: true
autoform:
placeholder: "John Doe"
email:
type: String
regEx: SimpleSchema.RegEx.Email
label: "E-mail address"
optional: true
autoform:
placeholder: "John@doe.com"
message:
type: String
label: "Message"
max: 1000
optional: true
autoform:
placeholder: "Message"
rows: 3
Contacts.attachSchema(Schemas.Contacts)
Run Code Online (Sandbox Code Playgroud)
视图/接触/ contact.html
<template name="contactPage">
<h2>Get in Contact</h2>
{{> quickForm
schema=contactFormSchema
id="contactForm"
type="method"
meteormethod="sendEmail"
template="bootstrap3-horizontal"
label-class="col-sm-3"
input-col-class="col-sm-9"
}}
</template>
Run Code Online (Sandbox Code Playgroud)
.meteor /包
coffeescript
aldeed:collection2
aldeed:simple-schema
aldeed:autoform
twbs:bootstrap
email
Run Code Online (Sandbox Code Playgroud)
视图/接触/ contact.coffee
if Meteor.isClient
Template.contactPage.helpers
contactFormSchema: ->
Schemas.Contacts
Run Code Online (Sandbox Code Playgroud)
服务器/ contact-send.coffee
if Meteor.isServer
Meteor.methods
sendEmail: (doc) ->
# Important server-side check for security and data integrity
check doc, Schemas.contacts
# Build the e-mail text
text = 'Name: ' + doc.name + '\n\n' + 'Email: ' + doc.email + '\n\n\n\n' + doc.message
@unblock()
console.log "about to send the email"
# Send the e-mail
Email.send
to: 'someone@somewhere.com'
from: doc.email
subject: 'Website Contact Form - Message From ' + doc.name
text: text
Run Code Online (Sandbox Code Playgroud)