2013-12-13 115 views
0

我尝试从我的form_tag发送参数,但在input_type我没有使用领域从模型。验证form_tag没有领域从模型在领域

我的form_tag代码:

<%= form_tag(wizard2_path, :method => :post, :multipart => true, :id => "form_wizard") do -%> 
    <fieldset> 
     <legend>Select your bill file</legend> 

     <!-- TODO: include a preview of the bill - zurb foundation supports this--> 
     <input id="bill" name="bill" type="file" />  
     <!-- TODO: automatically import once selected? --> 
     <!-- TODO: display right page after, original content 
     <input id="upload_bill" name="commit" type="submit" value="Upload bill" />| <a href="" onclick="$('#no_bill').show();$('#first_bill').hide();">Cancel</a> 

     --> 
     <div class="large-2 columns" > 
      <!-- TODO: make the browse button the zurb class type --> 
      <p> 
       <%#= link_to "Upload", "#", :onclick => "changeWizard('upload');", :id => "upload_btn1", :class => "button postfix"%> 
       <%= button_tag "Upload", :id => "upload_btn1", :class => "button postfix", :onclick=>"bill_upload_validation();" %> 
      </p> 
     </div> 
    </fieldset> 
<% end %> 

,如果我错了,请告诉我? 谢谢

回答

0

如果您不使用模型中的字段,那么您有权使用form_tag而不是form_for

在窗体中,您可以定义PARAMS:

<%= file_field_tag :bill %> 
<%= submit_tag 'Upload' %> 

任何验证必须是在这一点上,控制器(如果你不是用模型做任何事情)。

+0

谢谢你,解决我的问题 – tardjo