我有typeahead输入类型用于输入字段。
我希望能够像我在其架构中的其他[Meteor.ObjectID]类型(或可能是任何阵列类型)一样使用它。 {{> afQuickField}}
应该识别数组并将其包装在'afArrayField'模板中,为其提供精彩的添加/删除按钮和功能,并返回一个数组。
目前,我只是获取输入的一个实例和提交时的错误消息,说明该值必须是数组。
我正在搜索autoform's代码库,寻找如何在其他输入类型上实现它,但到目前为止没有运气,因为有很多代码。我只接受指向当前执行此操作的代码的指针。
更多信息
我在autoform-api.js中找到了AutoForm.getInputType
个功能。我可能不得不重载这个以获得我想要的行为。仍然欢迎更好的替代品!
也试过
所以我认为技巧可能是它响应了一组嵌套模式。不需要重载,只需将我的预先输入字段放入一个单独的模式中,然后将其嵌套在我的主模式中。
myTypeahead = new SimpleSchema({
item:{
type: Meteor.ObjectID,
autoform: {
type: "typeahead"
},
...
}
});
myMainSchema = new SimpleSchema({
itemId:{
type: [myTypeahead]
}
});
这就设置了添加/删除字段的功能。不足之处?现在,typeahead会像疯了一样抛出错误。
Exception in template helper: TypeError: Cannot read property 'lastIndexOf' of undefined
at inflectedLabel (/packages/aldeed_simple-schema.js?8fda161c43c0ba62801a10b0dfcc3eab75c6db88:2125:44)
at SimpleSchema.getDefinition (/packages/aldeed_simple-schema.js?8fda161c43c0ba62801a10b0dfcc3eab75c6db88:2670:30)
at Object.autoFormGetOptionsForField [as _getOptionsForField] (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:2690:12)
at Object.afOptionsFromSchema (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:1519:12)
at bindDataContext (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:16)
at Blaze._wrapCatchingExceptions (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:16)
at Object.Spacebars.call (/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:18)
at /client/template.person.js?684475f8f7f0a8f9fe76ecebd81f50a84a03f24d:142:30
at Blaze._TemplateWith.wrappedArgFunc (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2639:14)
at null.<anonymous> (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2445:26)
Exception in template helper: TypeError: undefined is not a function
at /packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:212:34
at /packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:176:29
at _.each._.forEach (/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:164:22)
at Function._.map._.collect (/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:175:5)
at Object.getSelectOptions (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:211:25)
at getInputData (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:1783:37)
at Object.afFieldInputContext (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:6999:17)
at bindDataContext (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:16)
at Blaze._wrapCatchingExceptions (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:16)
at Object.Spacebars.call (/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:18)
Exception in template helper: TypeError: Cannot read property 'class' of undefined
at Object.addClass (/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:641:20)
at Object.Template.afTypeahead.helpers.atts (/client/quickForm/autoform-typeahead.js?5037f57aba2aa1b9ec271e4ade183a5d126781e5:43:29)
at bindDataContext (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2727:16)
at Blaze._wrapCatchingExceptions (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1606:16)
at Spacebars.call (/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:171:18)
at Spacebars.mustacheImpl (/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:108:25)
at Object.Spacebars.attrMustache (/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:124:39)
at /client/quickForm/template.autoform-typeahead.js?e749e8ff2e104b2c1b5d2ca1f3f7bf538c5790e7:17:22
at Object.Blaze._withCurrentView (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
at Blaze._HTMLJSExpander.def.visitAttributes (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1962:21)
Exception from Tracker afterFlush function: Cannot read property 'atts' of undefined
TypeError: Cannot read property 'atts' of undefined
at Template.afTypeahead.rendered (/client/quickForm/autoform-typeahead.js?5037f57aba2aa1b9ec271e4ade183a5d126781e5:74:16)
at null.<anonymous> (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:3008:21)
at /packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1733:14
at Object.Blaze._withCurrentView (/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
at /packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1732:15
at Tracker.flush (/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:448:11)
答案 0 :(得分:0)
我看到同样的错误,但我不确定是否是出于同样的原因。您的整个{{&gt; afQuickField}}看起来像?我发现从标签中删除“选项”,或使用options = afOptionsFromSchema使错误消失。
使用options =“auto”不再有效。