How to display existing values on the autoForm field?


#1

Hi guys! I’m a newbie to Meteor and I got a problem with autoform tags here.

I have a collection Tags

Tags = new Mongo.Collection("tags");

schemaTagm= new SimpleSchema({ 
     asin: {
         label: "asin",
         type: String
     },
     content: {
         type: [String],
         optional: true,
         label: "Tags (Comma saperated)",
         autoform: {
              type: 'tags',
              tagClass: 'myTagClass',
              allowDuplicates: false
        }
    }
});

Tag has a value:

{
     asin: "1",
     content: ["books", "movies"]
}

html:

{{#autoForm collection="Tags" id="insertTags" type="insert"}}
   <fieldset>
      {{>afQuickField name="content"}}
   </fieldset>
<button type="submit" class="btn btn-primary">Add</button>
{{/autoForm}}

And what I get is the 1st image (left to right) shown below:

I actually want to display the existing content ([“books”, “movies”]) in this field, something like the 2nd image when the page is loaded.

Does anyone have any ideas about how to achieve this? Thanks a lot!

Alos, I can insert some random values in the filed like the 3rd image. But when I checked Tags.find({}).fetch() on the browser console, these values (aaa, bbb, ccc here) aren’t inserted in the collection. Does anybody can explain it?