Nested autoform: values need to be rendered twice before display


#1

Hi all! I’m using meteor autoform and yogiben:autoform-tags here to automatically display the values in my collections as editable tags. Here’s my collection:

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'
       }
}); 

Tags.attachSchema(schemaTagm); 

Here’s html code:

{{#autoForm collection='Tags' doc=mydoc id="updateiTagsForms" type="update"}}
   <fieldset>
       {{> afQuickField name="asin"}} 
     {{> afQuickField name="content"}} 
   </fieldset> 
   <button type="submit" class="btn btn-primary">Update</button>  
   {{/autoForm}}  

the program read some values from a json file and lead them to Tags collection. What I want here is to display these existing values when the page is loaded.

However, I got nothing in the “content” field when the page was firstly rendered but I got the correct “asin” in “asin” field. If I modified some piece of code and the page automatically reload after the modification, the values appear. Besides, when I remove the nested autoform part (type = “tags”), the “contents” can be displayed in the format of array field. I’m wondering if it’s because the tag part is a nested autoform so that it needs to wait until the “content” field get its values first. Can anyone help me out here? Thanks