An add-on Meteor package for aldeed:autoform. Provides a single custom input type, "universe-select".
This package is part of Universe, a framework based on Meteor platform maintained by Vazco.
It works standalone, but you can get max out of it when using the whole system.
http://universe-autoform-select.stg.vazco.eu/
https://github.com/vazco/meteor-universe-autoform-select-demo.git
The plugin library must be installed separately.
In a Meteor app directory, enter:
$ meteor add aldeed:autoform
In a Meteor app directory, enter:
$ meteor add vazco:universe-autoform-select
Universe selectize standalone:
https://github.com/vazco/meteor-universe-selectize/
Specify "universe-select" for the type
attribute of any input. This can be done in a number of ways:
In the schema, which will then work with a quickForm
or afQuickFields
:
{
tags: {
type: [String],
autoform: {
type: "universe-select",
afFieldInput: {
multiple: true
}
}
}
}
Or on the afFieldInput
component or any component that passes along attributes to afFieldInput
:
{{> afQuickField name="tags" type="universe-select" multiple=true}}
{{> afFormGroup name="tags" type="universe-select" multiple=true}}
{{> afFieldInput name="tags" type="universe-select" multiple=true}}
If you enable autosave option in autoform, then it triggering after blur of universe-select (if multiple).
universe-select options | |||
---|---|---|---|
Option | Description | Type | Default |
options |
Required. A function returning either an array of options, or a Mongo.Cursor . The function is re-evaluated automatically using Tracker when its reactive data sources change. |
function |
undefined |
uniPlaceholder |
Optional. A placeholder option. | String |
null |
optionsPlaceholder |
Optional. Show placeholder in options dropdown. | Boolean or String |
false |
uniDisabled |
Optional. | Boolean |
false |
multiple |
Optional. | Boolean |
false |
removeButton |
Optional. | Boolean |
true |
valuesLimit |
Optional. | Number |
undefined |
create |
Optional. Allows the user to create a new items that aren't in the list of options. | Boolean |
true |
createOnBlur |
Optional. If true, when user exits the field (clicks outside of input or presses ESC) new option is created and selected (if `create`-option is enabled). | Boolean |
true |
createSlug |
Optional. After creating new label, converts value into a slug. | Boolean |
true |
createMethod |
Optional. Name of method to call after create new item. Method can return new value for item. | function (label, value) |
undefined |
optionsMethod |
Optional. Name of method to get more items. Method should return array of options. | String |
undefined |
optionsMethodParams |
Optional. Additional params for optionsMethod. | Object |
undefined |
Meteor.methods({
getOptions: function (options) {
this.unblock();
var searchText = options.searchText;
var values = options.values;
if (searchText) {
return OptionsCollection.find({label: {$regex: searchText}}, {limit: 5}).fetch();
} else if (values.length) {
return OptionsCollection.find({value: {$in: values}}).fetch();
}
return OptionsCollection.find({}, {limit: 5}).fetch();
}
});
Like every package maintained by Vazco, Universe Autoform Select is MIT licensed.