larz
larz

Reputation: 871

Meteor - get field value with Autoform and Collection2

I have the following schema:

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>

but AutoForm.getFieldValue isn't working as expected. I want to get the field value of name and save it with the property code in my DB.

Upvotes: 0

Views: 76

Answers (1)

larz
larz

Reputation: 871

ok, I have to use 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'
        }
    }
});

Upvotes: 0

Related Questions