Reputation: 246
I am trying to use the quickform submit to server method and I don't think it's working. The console.log that I put inside the method seems to not be called when I press Submit.
Here's a demo for my problem. https://github.com/afifsohaili/quickform-demo
Server.js:
Volunteer = new Mongo.Collection("volunteer");
if (typeof Schema === "undefined") Schema = {};
Schema.volunteer = new SimpleSchema({
name: {
label: "Name",
max: 255,
type: String
},
birthdate: {
label: "Birthday / DD-MM-YYYY",
type: String
},
mobile_number: {
label: "Phone number",
type: String
},
email: {
label: "Email address",
type: "email"
},
facebook_url: {
label: "Facebook URL",
optional: true,
type: String
},
university: {
label: "University",
optional: true,
type: String
},
occupation: {
label: "Occupation",
optional: true,
type: String
},
male: {
autoform: {
class: "with-gap",
falseLabel: "Female",
trueLabel: "Male",
type: "boolean-radios",
},
label: " ",
type: Boolean
},
transport: {
autoform: {
type: "boolean-checkbox"
},
label: "I have my own transport",
type: Boolean
}
});
Meteor.methods({
registerVolunteer: function(doc) {
console.log(doc);
}
});
Html:
<head>
<title>test-quickform</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<div class="row">
<div class="col s12">
{{> quickForm schema="Schema.volunteer" id="newVolunteerForm"
type="method" meteormethod="registerVolunteer"
buttonClasses="pink accent-3 waves-effect waves-light btn"
buttonContent="Continue" }}
</div>
</div>
</template>
Upvotes: 0
Views: 90
Reputation: 1146
createdAt type: "hidden"
still being validate on client and prevent method call due to no value. Try add optional: true
and set the value on server.
BTW, createdAt attribute is missing on your question.
Upvotes: 1
Reputation: 21259
Your form validation is failing, which prevent calling the "registerVolunteer". Check your schema
// Run "before.method" hooks // 14
this.runBeforeHooks(this.insertDoc, function (doc) { // 15
// Validate. If both schema and collection were provided, then we validate // 16
// against the collection schema here. Otherwise we validate against whichever // 17
// one was passed. // 18
var valid = (c.formAttributes.validation === 'none') || // 19
c.formTypeDefinition.validateForm.call({ // 20
form: c.formAttributes, // 21
formDoc: doc, // 22
useCollectionSchema: c.ssIsOverride // 23
}); // 24
// 25
if (valid === false) { // 26
c.failedValidation(); // <- Your code stops here // 27
}
Upvotes: 0