【问题标题】:Meteor - get field value with Autoform and Collection2Meteor - 使用 Autoform 和 Collection2 获取字段值
【发布时间】:2016-08-08 04:29:54
【问题描述】:

我有以下架构:

GuestSchema = new SimpleSchema({
    name: {
        type: String,
        label: 'Name'
    }
    code: {
        type: String,
        label: 'Code',
        autoValue: function(){
            return AutoForm.getFieldValue('name', 'insertGuestForm');
        },
        autoform: {
            type: 'hidden'
        }
    }
});

<template name="NewGuest">
    <div class="new-guest">
        {{> quickForm collection="Guests" id="insertGuestForm" type="insert" class="new-guest-form"}}
    </div>
</template>

但是AutoForm.getFieldValue 没有按预期工作。我想获取name 的字段值并将其与属性code 一起保存在我的数据库中。

【问题讨论】:

    标签: meteor meteor-autoform meteor-collection2


    【解决方案1】:

    好的,我必须使用this.field("name");

    GuestSchema = new SimpleSchema({
        name: {
            type: String,
            label: 'Name'
        }
        code: {
            type: String,
            label: 'Code',
            autoValue: function(){
                var content = this.field("name");
                return content.value;
            },
            autoform: {
                type: 'hidden'
            }
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 2016-12-14
      • 2016-10-08
      • 1970-01-01
      • 2015-03-09
      相关资源
      最近更新 更多