Reputation: 3749
Problem: when I enter the client/_form.haml, a group is autoselected by selectize.js, whereas I want the field to be blank by default, unless I start typing or enter the dropdown.
I am using the gem "selectize-rails"
.
Student has many Groups.
Main.js:
/*global $*/
/*global app*/
$(document).ready(function(){
if ($('.selectize')){
$('.selectize').selectize({
sortField: 'text'
});
}
});
student/_form.haml:
= simple_form_for(@client_group) do |f|
.form-inputs
= f.input :client_name
= f.select :group_id, Group.all.map{|c| [c, c.id]}, {},class: 'selectize'
.form-actions
= f.button :submit, class: 'btn btn-primary'
Upvotes: 0
Views: 475
Reputation: 3749
Adding include_blank: true
fixes the problem:
= f.select :group_id, Group.all.map{|c| [c, c.id]}, {include_blank: true},class: 'selectize'
Upvotes: 1