2014-09-30 79 views
0

我遇到了haml格式的条纹问题。我无法让我的提交功能。这是我第一次用智慧建立一个机会,任何投入都会有所帮助。我甚至不确定我的字段是否设置正确以保存到数据库中。HAML表格不会提交

.container 
     %section#checkout-form 
     = form_tag("", method: "POST", id: "payment-form") do 
      .row 
      #checkout-form.small-8.columns 
       .row 
       #name-form.small-12.columns 
        .row 
        .small-6.columns 
         = label_tag :frist_name, "First Name" 
         = text_field_tag :name => "First Name", :placeholder => "John", :type => "text" 
        .small-6.columns 
         = label_tag :Last_Name, "Last Name" 
         = text_field_tag :name => "Last Name", :placeholder => "Smith", :type => "text" 
        .row 
        .small-12.columns 
         = label_tag :Email, "Email" 
         = text_field_tag :name => "Email", :placeholder => "[email protected]", :type => "text" 
       #address-info.small-12.columns 
        .row 
        .small-12.columns 
         = label_tag :Address1, "Address 1" 
         = text_field_tag :name => "Address1", :placeholder => "123 Street", :type => "text" 
        .row 
        .small-12.columns 
         = label_tag :Address2, "Address 2" 
         = text_field_tag :name => "Address2", :placeholder => "Apartment/Suite", :type => "text" 
        .row 
        .small-6.columns 
         = label_tag :City, "City" 
         = text_field_tag :name => "City", :placeholder => "test", :type => "text" 
        .small-6.columns 
         = label_tag :State, "State" 
         = text_field_tag :name => "State", :placeholder => "test", :type => "text" 
        .row 
        .small-6.columns 
         = label_tag :ZIP, "ZIP" 
         = text_field_tag :name => "ZIP", :placeholder => "64804", :type => "text" 
        .small-6.columns 
         = label_tag :Country, 'Country' 
         = text_field_tag :name => "Country", :placeholder => "USA", :type => "text" 
       #billing-info.small-12.columns 
        .row 
        .small-6.columns 
         = label_tag :Credit_Card_Number, "Credit Card Number" 
         = text_field_tag :name => "Credit Card Number", :placeholder => "1234 5678 9055 5555", :type => "text" 
        .small-3.columns 
         = label_tag :Month, "Month" 
         = select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month", class: 'minilabel', "data-stripe" => 'exp-month'} 
        .small-3.columns 
         = label_tag :Year, "Year" 
         = select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year", "data-stripe" => 'exp-year'} 
        .row 
        .small-6.columns 
         = label_tag :Security_Code, 'Security Code' 
         = text_field_tag :name => "Security Code", :placeholder => "123", :type => "text" 
        .small-6.columns 
         = label_tag :Billing_ZIP, 'Billing ZIP' 
         = text_field_tag :name => "Billing ZIP", :placeholder => "64804", :type => "text" 
      /Form Side 
      #checkout-info.small-4.columns 
      /Info Side 
       %img#cards-image{:alt => "", :src => image_path("cards.svg")}/ 
       .hr-with-margin 
       .reward 
       %h4 $25 Per Month 
       %h5 21 people 
       %p text 
       %a.button.button-green{:href => "#"} Pledge 
     /row 
      .row.pad-top 
      .small-12.columns 
       %submit.button.button-green{type: "submit"} Submit Payment 

在先进的感谢。

回答

1

如果您的表单使用的是form_tag,则需要为您的提交按钮使用submit_tag。它应该是这样的:

= submit_tag "Submit", :class=> "button button-green" 

,并确保该submit_tag嵌套在form_tag内。

而且,你在做你的表单标签下面:

= form_tag("", method: "POST", id: "payment-form") do 

但你不是指定的形式提交给路线。第一个参数是用于指定路线。所以,你可以做这样的事情:

= form_tag('/users, method: 'POST', id: 'payment-form') do 

,如果你想发布到'/users'路线