aldeed:autoform-select2
An add-on Meteor package for aldeed:autoform. Provides a single custom input type, "select2", which renders an input using the select2 plugin.
Prerequisites
The plugin library must be installed separately.
In a Meteor app directory, enter:
$ meteor add natestrauser:select2 $ meteor add aldeed:autoform
If using with bootstrap, you'll probably also want to:
$ meteor add zimme:select2-bootstrap3-css
Installation
In a Meteor app directory, enter:
$ meteor add aldeed:autoform-select2
Usage
Specify "select2" 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
:
1{ 2 tags: { 3 type: [String], 4 autoform: { 5 type: "select2", 6 afFieldInput: { 7 multiple: true 8 } 9 } 10 } 11}
Or on the afFieldInput
component or any component that passes along attributes to afFieldInput
:
1{{> afQuickField name="tags" type="select2" multiple=true}} 2 3{{> afFormGroup name="tags" type="select2" multiple=true}} 4 5{{> afFieldInput name="tags" type="select2" multiple=true}}
To provide select2 options, set a select2Options
attribute equal to a helper that returns the options object. Most of the data-
attributes that the plugin recognizes should also work.
Demo
Limitations
Currently only select
element features are supported. If you would like to add support for hidden input
element features, please do so and submit a pull request.
Contributing
Anyone is welcome to contribute. Fork, make your changes, and then submit a pull request.