2017-10-10 137 views
0

我是新來的流星,我必須從aldeed/meteor-autoform流星多重選擇自動窗體錯誤

與流星自動窗體的問題,我想實現一個多選擇框。

Exercises = new Mongo.Collection('exercises'); 
ExerciseSchema = new SimpleSchema({ 
name: { 
    label: "Name", 
    type: String 
}, 
tags: { 
    label: "Tags", 
    type: Tags 
}}); 

Tags = new SimpleSchema({ 
wow: { 
    type: String, 
    allowedValues: ['red', 'green', 'blue'], 
    autoform: { 
     options: [ 
      {label: "Red", value: "red"}, 
      {label: "Green", value: "green"}, 
      {label: "Blue", value: "blue"} 
     ] 
    } 
}}); 

而且在我的HTML我插入

{{#autoForm collection="Exercises" id="insertExerciseForm" type="insert" resetOnSuccess=true}} 
      <div class="card-content"> 
       {{> afQuickField name='tags.wow' type='select-multiple'}} 
      </div> 

在瀏覽器,它看起來是正確的像 Multiple select box select

但是,當我選擇多個元素,並從我的自動窗體點擊提交按鈕,我得到此錯誤在我的瀏覽器控制檯中:

Error in insertExerciseForm insert Error: Wow must be of type String 

當我從afQuickField中刪除type ='select-multiple'時,我只能選擇一個元素,並且工作正常。但我需要選擇多個元素

有人可以幫助我嗎?

感謝很多:) 很遺憾我Englisch

回答

0

[字符串]於事無補。

我發現了。

Tags = new SimpleSchema({ 
wow: { 
type: Array, 
allowedValues: ['red', 'green', 'blue'], 
autoform: { 
    options: [ 
     {label: "Red", value: "red"}, 
     {label: "Green", value: "green"}, 
     {label: "Blue", value: "blue"} 
    ] 
},'wow.$': { 
    type: String 
}, 
}}); 

但現在,它只是將值保存在MongoDB中,我怎樣才能保存標籤和值?