I use meteor-autoform
to insert documents in a collection. My Items
has a field groupId
. How can I insert this group id when I'm submitting my item form.
<template name="itemForm">
{{#autoForm type="insert" collection=Collections.Items}}
{{> afQuickField name="name"}}
<div class="form-group">
<button type="submit" class="btn btn-primary">Add item</button>
<button type="reset" class="btn btn-default">Reset Form</button>
</div>
{{/autoForm}}
</template>
I could create another field containing my group id but I don't want the user to see this field.
How can I set the groupId
"behind the scenes"?
For that, you need a hook. Also you need to set an ID for the form, let's say
addItemForm
.