0

My end goal is to create a checkbox that, when selected, checks all the checkboxes in a form. And un-checks them all when it changes from checked to unchecked. All the posts I've seen (this one and also this one) requires the use of the name of my form. What IS the name of my form? Here's my entire view:

<%= render 'admin/distributions/head' %>
<% title 'Workflow' %>


<%= form_for @search, :url => url_for(:controller => params[:controller], :action => params[:action]), :html => {id => "distribution_workflow",:method => :get} do |f| %>

  <div class="opportunity-block yellow">

    <div class="form-block mrl mbm">
      <%= f.label :created_at_gt, "Created at >" %>
      <%= f.text_field :created_at_gt, :class => "js-db-date-picker" %>
    </div>

    <div class="form-block mrl mbm">
      <%= f.label :created_at_lte, "Created at <=" %>
      <%= f.text_field :created_at_lte, :class => "js-db-date-picker" %>
    </div>

    <div class="form-block mrl mbm mtm">
      <%= f.label :status_equal, "Status" %>
      <%= f.select :status_equal, Distribution.select(:status).group(:status).order(:status).map { |d| [d.status] }, :include_blank => " " %>
    </div>

    <div class="clear"></div>
    <%= submit_tag 'Apply Filter', :class => "input-button dark unit-right mrl" %>
    <div class="clear"></div>
  </div>
<% end  %>


<%= form_tag edit_multiple_admin_distributions_workflows_path do %>
<%= submit_tag "Edit Selected" %>
  <table class="standard-grid">
    <tr>
      <th class="first">
      </th> 
      <th>ID</th>
      <th>Customer</th>
      <th>Resume URL</th>
      <th>Partner</th>
      <th>Status</th>
      <th>Assigned To</th>
      <th>Comments</th>
      <th></th>
    </tr>
    <% @report.each do |distribution| %>
      <tr>
        <td><%= check_box_tag "distribution_ids[]", distribution.id %></td>
        <td>
          <%= distribution.owner.id %>
        </td>
        <td>
          <%=link_to distribution.owner.full_name, "mailto:#{distribution.owner.email}" %>
        </td>
        <td>
          <a href=<% UrlService.download_blob_url(distribution.resume) %>>Resume URL</a>
        </td>
        <td>
          <%=link_to distribution.matching_profile.partner.title,  "mailto:#{distribution.matching_profile.partner.email}" %>
        </td>
        <td>
          <%= distribution.status %>
        </td>
        <td>
          <%= distribution.assignee_id %>
        </td>
        <td>
          <%= distribution.comments %>
        </td>
      </tr>
    <% end %>
  </table>
<% end %>
Community
  • 1
  • 1
Ramy
  • 20,541
  • 41
  • 103
  • 153

2 Answers2

4

Form name is not automatically set in Rails, but however you can set name to a form by passing html_options.

Eg.: <%= form_for(@obj, :html => { :name => "test" }) do |f| %>
Syed Aslam
  • 8,707
  • 5
  • 40
  • 54
0

You have two form tags here, but what you are looking for is the ID of the form, not the NAME.

The jQuery that the links you posted are referencing looks like this:

$("#my_form")...

The # indicates ID, so if the ID of your form is:

<form id="some_id_here">

You would use:

$("#some_id_here")...

In order to find this, you can right click on the element on the page (when you are viewing the actual page) - and click "Inspect Element." This is in Chrome/Firefox/Safari. I can't remember exactly what it's called in IE, but you get the gist.

andrewpthorp
  • 4,998
  • 8
  • 35
  • 56
  • this brings up two questions. 1.) will the form ID always be the same across environments (local, dev, staging, production)? and 2.) why am I unable to see this in chrome?? – Ramy Dec 20 '11 at 20:18