Meteor - 使用Meteor.users集合进行Autoform

时间:2015-03-19 00:26:04

标签: meteor meteor-autoform

使用Autoform和Meteor.users创建一个小测试。如果我创建自己的集合,那很好。但不知怎的,我不断得到这个错误,我不知道什么是错的..

错误:

Uncaught RangeError: Maximum call stack size exceeded
14autoform-inputs.js:162 Uncaught TypeError: Cannot read property 'formValues' of undefined

模板:     

    {{> loginButtons}}

    <div class="container">
        <h2>update</h2>
        {{> update }}
    </div>  
</body>

<template name="update">
  {{> quickForm collection="Meteor.users" 
                id="update-user-profile" 
                type="update" 
                doc="user"
            }}
</template>

让helper返回当前用户的方案:

Meteor.users.attachSchema(new SimpleSchema({
    country: {
        type: String,
        label: "Country"
    },
    city: {
        type: String,
        label: "city"
    },
    email: {
        type: String,
        label: "email"
    },
    story: {
        type: String,
        label: "your story",
        optional: true,
        max: 1000
    }
}));

if (Meteor.isClient) {

    Template.update.helpers({
        user: function(){
            return Meteor.userId();
        }
    });    
}

1 个答案:

答案 0 :(得分:0)

您只需删除用户

的引号即可

doc="user"更改为doc=user

您的模板应如下所示

<template name="update">
  {{> quickForm collection="Meteor.users" 
                id="update-user-profile" 
                type="update" 
                doc=user
            }}
</template>

查看此MeteorPad