[英]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.