Метеор - получить значение поля с помощью Autoform и Collection2

У меня есть следующая схема:

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 в моей БД.


person larz    schedule 07.08.2016    source источник


Ответы (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'
        }
    }
});
person larz    schedule 07.08.2016