2016-02-28 82 views
0

我試圖添加具有三個選項 下拉類別字段,這是我對這個功能下拉列表

category: { 
    type: String, 
    allowedValues: ["Android","IOS","Unity"], 
    autoform: { 
     afFieldInput: { 
     firstOption: "(Select the Category)" 
     } 
    } 
    } 

當我使用這段代碼

{{> quickForm collection="Products" id="insertProductForm" type="insert"}} 

它工作正常碼下拉列表顯示正常,但當我使用下面的代碼來獲取表格

{{#autoForm collection="Products" id="inserP" type="insert"}} 
    <fieldset> 
     {{> afQuickField name='category'}} 
    </fieldset> 
    <button type="submit" class="btn btn-primary">Submit</button> 
    {{/autoForm}} 

我可以看到類別字段,但沒有下拉菜單(接受字符輸入的普通字段)

如何使用afQuickField顯示下拉列表?

回答

2

docs中,有afFieldInput選項,它允許我們指定如何構建每個輸入元素。

在你的情況下,代碼將變爲:

{{#autoForm collection="Products" id="inserP" type="insert"}} 
    <fieldset> 
     {{> afFieldInput name='category' type='select' options='allowed'}} 
    </fieldset> 
    <button type="submit" class="btn btn-primary">Submit</button> 
{{/autoForm}} 

type='select'指定輸入字段的類型使用。

options='allowed'指定我們要使用架構中的allowedValues

+0

感謝它的工作 –