Skip to content

Instantly share code, notes, and snippets.

@ahmad19
Created December 29, 2020 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmad19/fc5b1fcc8f275b336c701287c7fb4a50 to your computer and use it in GitHub Desktop.
Save ahmad19/fc5b1fcc8f275b336c701287c7fb4a50 to your computer and use it in GitHub Desktop.
Rails example of an ajax form with a select_tag of grouped options
<%= form_tag(submit_path, remote: true, method: :get, id: 'add_line_item') do %>
<div class="col">
<div class="form-row">
<div class="col-md-10">
<%= grouped_collection_select(:line_item, :product_id, current_user.categories, :products, :name, :id, :name, { prompt: '--Select Product--' }, { class: 'form-control form-control-sm' }) %>
</div>
<div class="col text-center">
<%= submit_tag 'Add', class: 'btn btn-outline-secondary btn-sm'%>
</div>
</div>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment