HAML表格不会提交

时间:2014-09-30 23:13:17

标签: ruby-on-rails forms haml stripe-payments

我遇到条纹的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 => "test@test.com", :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 个答案:

答案 0 :(得分: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'路线