I done grouped_options_for_select. I want a prompt. If there no options to select under the group, there should not any space. I try with the following code.
controller:
@grouped_options = @subjects.inject({}) do |options, product|
(options[product.subject_name] ||= []) << [product.module_name, product.subject_module_id]
options
end
view:
<div id="subject_module_drp_div">
<%= f.select :subject_module_id, grouped_options_for_select(@grouped_options),
{:class=>"form-control select_modules",:style=>"width:100%;"} %>
</div>
my options for select like,
Grammar:
Tense
VoiceScience:
Maths:
Algebra
Trignomentry
Here Science has no option to select. So maths comes immediate next to science. There is no space between science and maths. Is there any option to do this in the grouped_options_for_select. And how to give prompt value and get already selected options.
Smile & Thanks.