Planifica/meteor-wizard的文档告诉我们,SimpleSchema应该作为模板的一部分来创建。我将所有的Simple-Schema都作为我的集合的一部分,并希望保持这种方式。有没有人知道这是否可以用Planifica/meteor-wizard来完成?
发布于 2015-09-30 15:20:49
在哪里定义它应该无关紧要。但在查看流星巫师的文档时,看起来你至少需要一个参考。
因此,您只需返回对模式的引用,而不是定义模式的帮助器。因此,如果您使用文档示例。而不是:
Template.setupStepOne.schema = function() {
return new SimpleSchema({
...
});
}您可以使用:
Template.setupStepOne.schema = CollectionName.Schema;只需在存储模式的位置将CollectionName.Schema替换为。
发布于 2015-10-08 10:39:56
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'
}
});
}https://stackoverflow.com/questions/32859777
复制相似问题