[英]How to use placeholder with Meteor AutoForm select2?
我正在使用 AutoForm 包,包括 Meteor 的 select2 擴展。
奧爾迪德:自動成型
aldeed:autoform-select2
autoform-select2 上的文檔告訴我我可以像這樣設置 use select2Options:
{{> afQuickField name='finalReviewerComments'select2Options=select2Options}}
我的架構:
finalReviewerComments: {
type: String,
max: 20,
autoform: {
options: [
{label: "Good", value: 0},
{label: "9: Grammar/spelling/formatting/readability", value: 9},
{label: "8: Not a finding", value: 8},
{label: "7: Information missing", value: 7},
{label: "6: Repeated/combined finding", value: 6},
{label: "5: FAQ requirements", value: 5},
{label: "4: Multiple findings in one", value: 4},
{label: "3: Context missing", value: 3},
{label: "2: Country/page number error", value: 2},
{label: "1: Misinterpretation", value: 1}
],
type: "select2"
},
optional: true
}
我嘗試將其添加到 autoform 中的架構中:
afFieldInput: {
select2Options: {
placeholder: "Imaginary text here"
}
}
並使用文檔中指出的輔助函數 select2Options :
Template.finalReview.helpers({
select2Options: function () {
return {placeholder: "Final Review Comments"};
}
});
這兩個選項都不起作用。 我怎樣才能讓它工作? 呈現表單時,我想要一個空的 select2 輸入框。
編輯:只是為了澄清: {allowclear: true}
也不起作用。
占位符默認為空白。 要添加實際值,這是有效的,如文檔所述:
幫助文件:
Template.testTemplate.helpers({
select2Options: function () {
return {placeholder: "Find a dataset"};
}
})
模板文件:
<template name="testTemplate">
{{#autoForm id='addDatasetForm' schema=datasetsSchema type='normal' class="form-horizontal" validation='keyup'}}
{{> afQuickField class='select2 select-css' name=dataset_name options=getDatasets size=10 select2Options=select2Options}}
{{/autoForm}}
</template>
雖然現在我已經提供了這個答案,但占位符似乎沒有在第一次呈現模板時出現。 這個特定的字段是數組字段的一部分,只有在我刪除然后將元素重新添加到數組字段后才會顯示。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.