首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >流星计划/流星向导

流星计划/流星向导
EN

Stack Overflow用户
提问于 2015-09-30 14:59:12
回答 2查看 188关注 0票数 1

Planifica/meteor-wizard的文档告诉我们,SimpleSchema应该作为模板的一部分来创建。我将所有的Simple-Schema都作为我的集合的一部分,并希望保持这种方式。有没有人知道这是否可以用Planifica/meteor-wizard来完成?

EN

回答 2

Stack Overflow用户

发布于 2015-09-30 15:20:49

在哪里定义它应该无关紧要。但在查看流星巫师的文档时,看起来你至少需要一个参考。

因此,您只需返回对模式的引用,而不是定义模式的帮助器。因此,如果您使用文档示例。而不是:

代码语言:javascript
复制
Template.setupStepOne.schema = function() {
  return new SimpleSchema({
    ...
  });
}

您可以使用:

代码语言:javascript
复制
Template.setupStepOne.schema = CollectionName.Schema;

只需在存储模式的位置将CollectionName.Schema替换为。

票数 2
EN

Stack Overflow用户

发布于 2015-10-08 10:39:56

代码语言:javascript
复制
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'
    }
  });
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32859777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档