I am currently trying to make a field that inserts whatever the user inserts into it into the database. I am currently trying to make a database called "UserRecords" so that when they submit the form, it accesses the database and updates the "UserRecords" database with what the user inserted into the field. For now, the only field that I am trying to connect is the "address" field.
This is my both/config.js file:
UserRecords = new Mongo.Collection("userrecords");
AccountsTemplates.configure({
// Behavior
confirmPassword: true,
enablePasswordChange: true,
forbidClientAccountCreation: false,
overrideLoginErrors: true,
sendVerificationEmail: true,
lowercaseUsername: false,
focusFirstInput: true,
// Appearance
showAddRemoveServices: false,
showForgotPasswordLink: true,
showLabels: true,
showPlaceholders: true,
showResendVerificationEmailLink: true,
// Client-side Validation
continuousValidation: false,
negativeFeedback: false,
negativeValidation: true,
positiveValidation: true,
positiveFeedback: true,
showValidating: true,
// Privacy Policy and Terms of Use
privacyUrl: 'privacy',
termsUrl: 'terms-of-use',
// Redirects
homeRoutePath: '/map',
redirectTimeout: 4000,
});
AccountsTemplates.addField({
_id: "address",
type: "text",
displayName: "Address",
placeholder: {
signUp: "Your Address"
},
});
AccountsTemplates.addField({
_id: "pilotorcustomer",
type: "radio",
displayName: "Are You A Pilot Or Looking For A Service",
required: true,
select: [
{
text: "Pilot",
value: "aa",
}, {
text: "Customer",
value: "bb",
},
],
});
If anyone wants to view the whole file, it is available on github via the link:
https://github.com/Aggr0vatE/testbasichelp
Thank You In Advance,
Stephen
Ok, so I solved the question by adding a global variable to the AccountTemplates.addField and then making a function to call the varialeb to insert it into the database.
This is the finished config.js code:
UserRecords = new Mongo.Collection("userrecords");
insertDatabase = function (address) {
UserRecords.insert({
Address: address._id,
});
};
AccountsTemplates.configure({
// Behavior
confirmPassword: true,
enablePasswordChange: true,
forbidClientAccountCreation: false,
overrideLoginErrors: true,
sendVerificationEmail: true,
lowercaseUsername: false,
focusFirstInput: true,
// Appearance
showAddRemoveServices: false,
showForgotPasswordLink: true,
showLabels: true,
showPlaceholders: true,
showResendVerificationEmailLink: true,
// Client-side Validation
continuousValidation: false,
negativeFeedback: false,
negativeValidation: true,
positiveValidation: true,
positiveFeedback: true,
showValidating: true,
// Privacy Policy and Terms of Use
privacyUrl: 'privacy',
termsUrl: 'terms-of-use',
// Redirects
homeRoutePath: '/map',
redirectTimeout: 4000,
});
address = AccountsTemplates.addField({
_id: "address",
type: "text",
displayName: "Address",
required: true,
placeholder: {
signUp: "Your Address"
},
});
AccountsTemplates.addField({
_id: "pilotorcustomer",
type: "radio",
displayName: "Are You A Pilot Or Looking For A Service",
required: true,
select: [
{
text: "Pilot",
value: "aa",
}, {
text: "Customer",
value: "bb",
},
],
});