0

I am new to ROR and am trying to pass two variables from two fields in a view to a controller to generate a dataset for an excel export. The excel export works, however all I get are headers and no data. I know it's because the parameters aren't being passed to the controller.

Here's the code. The SQL has been shortened... In View

    <table border="0" cellspacing="0" cellpadding="10">
      <tr>
        <td style="text-align: left; width:400px;"> Enter any part of a BU Manager Name, Subcontractor name, Subcontractor ID, PO Number, CRN or SCA name:</td>
        <td style="text-align: left;">
          <% form_tag  :controller => 'subcontracts', :action => 'show_active_subcontracts_results', :method => 'get' do %>
            <p>
              <%= text_field_tag :search, params[:search] , :id => 'search_field' %>
            </p>
        <td>
            <p>
              Expand Contract Period:
              <%=  select_tag 'c_end_date', options_for_select([["Current Subcontracts", "1"],["Past 5 Years", "2"], ["All", "3"]],{:mutiple => false}) %>
              <%= submit_tag "Update", :name => nil %>
              <%= link_to_function "Clear", "$('search_field').clear()" %>
              <%= link_to 'Export To Excel',:action=>'active_subcontracts_to_excel',  :format=> 'excel'  %>

              </p>
        </td>
          <% end %>
        </td>            
      </tr>          
    </table>

What I want to do is pass the 'c_end_date' and 'search' data to the controller. Not sure if the link_to is the correct way.

Thank you for your help.

1 Answer 1

2

Your html is invalid: between the td above your form tag you're starting another td inside the form tag where the opening td hasn't been closed yet. This could be breaking your form. Try taking that td out entirely.

Sign up to request clarification or add additional context in comments.

1 Comment

Stack overflow nicely points this out by strange syntax highlighting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.