Volt::Select2
Simple wrapper to use select2 with Volt
Installation
Add this line to your application's Gemfile:
gem 'volt-select2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install volt-select2
Usage
Initilize an select2 field:
<:select2:field include_blank="true" placeholder="Some placeholder" options="{{ ['test', 'test2'] }}" value="{{ params._selected }}" html_class="form-control">
- You can add a placeholder via the
placeholder
attr. - The
include_blank
attr includes a blank field and adds theallowClear
option to the select2 field options
can either be an array or a hash (Volt::Model
)value
will be set to the selected option
For a select2 field with multiple option you can use the follow tag <:select2:field:multiple placeholder="Some placeholder" options="['test', 'test2'] }" value="params._selected }" html_class="form-control" />
Contributing
- Fork it ( http://github.com/[my-github-username]/volt-select2/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request