Reputation: 2687
The documentation of Planifica/meteor-wizard tells that the SimpleSchema should be created as part of the template. I have all my Simple-Schema's as part of my collection and would like to keep it that way. Anyone knows if this can be done with Planifica/meteor-wizard?
Upvotes: 1
Views: 200
Reputation: 270
Install first $ meteor add planifica:wizard
Please check bellow added small program. I think it is helpful for you.
<template name="setupWizard">
{{> wizard id="setup-wizard" steps=steps}}
</template>
<template name="setupStepOne">
{{#autoForm schema=schema doc=data id="setup-step-one-form"}}
{{> afQuickField name="username"}}
{{> afQuickField name="password"}}
<button type="submit" class="btn btn-success btn-lg pull-right">Next</button>
{{/autoForm}}
</template>
<template name="setupStepTwo">
{{#autoForm schema=schema doc=data id="setup-step-two-form"}}
{{> afQuickField name="confirm"}}
<button type="submit" class="btn btn-success btn-lg pull-right">Submit</button>
{{/autoForm}}
</template>
Then configure your schema's and steps
Template.setupWizard.steps = function() {
return [{
id: 'stepOne',
title: 'Step 1. Your account',
template: 'setupStepOne',
formId: 'setup-step-one-form'
}, {
id: 'stepTwo',
title: 'Step 2. Confirm',
template: 'setupStepTwo',
formId: 'setup-step-two-form',
onSubmit: function(data, mergedData) {
Accounts.createUser(mergedData, function(err) {
if(!err) Router.go('/');
});
}
}]
}
Template.setupStepOne.schema = function() {
return new SimpleSchema({
'username': {
type: String,
label: 'Username',
min: 2,
max: 30
},
'password': {
type: String,
label: 'Password',
min: 6
}
});
}
Template.setupStepTwo.schema = function() {
return new SimpleSchema({
'password': {
type: Boolean,
label: 'Confirm your registration'
}
});
}
Upvotes: 1
Reputation: 106
It should not matter where you define it. But in looking at the meteor-wizard docs it does look like you at least need a reference to it.
So instead of a helper that defines the schema, you just return a reference to it. So if you use the documentation example. Instead of:
Template.setupStepOne.schema = function() {
return new SimpleSchema({
...
});
}
You could use:
Template.setupStepOne.schema = CollectionName.Schema;
Just replace the CollectionName.Schema with a wherever you are storing your schema.
Upvotes: 2