-
Notifications
You must be signed in to change notification settings - Fork 1
fake checkboxes
<%= form_tag bulk_assign_manage_workorders_path, id: "workorder_bulk_edit_form", style: 'display: none;' do |f| %>
<%= select_tag :assignee_id, options_from_collection_for_select(@operations_users, :id, :short_name) %>
<button type="submit">Bulk Assign</button>
<a <%= fake_deselect_attrs %>>deselect all</a>
<% end &>
<% @workorders.each do |workorder| %>
<div <%= fake_checkbox_attrs('#workorder_bulk_edit_form', 'workorder_ids[]', workorder.id, toggle_form: true) %> >
</div>
<%= workorder.description %>
<% end %>
In the above example, a list of workorders shows checkboxes next to each. Clicking one of the checkboxes will cause the bulk assignment form above to appear. Deselecting all of the workorders causes the form to disappear again. Submitting the form will send not only the assignee_id, but an array of the selected workorder ids for assignment.
Use this helper to designate a checkbox that should be connected to the form described by form_selector.
field_name
- the name of the input element that will be added to the form if this box is checked.
field_value
- the value that will be set on the input element.
toggle_form
- tells hooch to hide the form if all the checkboxes are deselected at the same time.
Use this helper to tell hooch that clicking this element should deselect all the checkboxes associated with the enclosing form element.