Метеоритная автоформ a _id field

У меня есть эта схема:

Schemas = {};

Schemas.Id = {
    type: String,
    optional: true,
    label: 'Id',
    //max: ID_LENGTH,
    defaultValue : Random.id(ID_LENGTH),
    denyUpdate: true
};

Schemas.Name = {
    type: String,
    label: 'Name',
    max: 75
};

Schemas.Description = {
    type: String,
    label: 'Description',
    max: 500,
    optional: true,
    autoform: {
        rows: 5
    }
};

//-- Attribute
Schemas.Attribute = {
    _id: Schemas.Id,
    attribute_name : Schemas.Name,
    attribute_description : Schemas.Description
};

Collections.Attributes.attachSchema(Schemas.Attribute);

у меня есть запрос от клиента, который они могут вставить _id вручную. но автоформа не может разрешить это, этот шаблон:

<template name="pg_attr_insert">
    {{#autoForm _id="afInsertDemo" type="insert" collection=Collections.Attributes}}
        <div class="form-group {{#if afFieldIsInvalid name='_id'}}has-error{{/if}}">
            <label class="control-label">{{afFieldLabelText name='_id'}}</label>
            {{> afFieldInput name='_id'}}
            {{#if afFieldIsInvalid name='_id'}}
                <span class="help-block">{{{afFieldMessattribute_description name='_id'}}}</span>
            {{/if}}
        </div>
        <div class="form-group {{#if afFieldIsInvalid name='attribute_name'}}has-error{{/if}}">
            <label class="control-label">{{afFieldLabelText name='attribute_name'}}</label>
            {{> afFieldInput name='attribute_name'}}
            {{#if afFieldIsInvalid name='attribute_name'}}
                <span class="help-block">{{{afFieldMessattribute_description name='attribute_name'}}}</span>
            {{/if}}
        </div>
        <div class="form-group {{#if afFieldIsInvalid name='attribute_description'}}has-error{{/if}}">
            <label class="control-label">{{afFieldLabelText name='attribute_description'}}</label>
            {{> afFieldInput name='attribute_description'}}
            {{#if afFieldIsInvalid name='attribute_description'}}
                <span class="help-block">{{{afFieldMessattribute_description name='attribute_description'}}}</span>
            {{/if}}
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Add Person</button>
            <button type="reset" class="btn btn-default">Reset Form</button>
        </div>
    {{/autoForm}}
</template>

это ошибка:

Uncaught Error: каждый autoForm и quickForm должен иметь атрибут "id", установленный на уникальную строку.

есть ли в любом случае автоформ разрешения на вставку _id вручную? и как?

1 ответ

Оке, я знаю, что мой ложный

{{#autoForm _id="afInsertDemo" type="insert" collection=Collections.Attributes}}

я просто конвертирую это в:

{{#autoForm id="afInsertDemo" type="insert" collection=Collections.Attributes}}
Другие вопросы по тегам