表单标签未显示在haml文件中 [英] Form tag not showing up in haml file
问题描述
我正在尝试在模态中获取表格.表单标签之后的所有内容都会显示出来,但那里的实际表单标签无法提交.我在其他页面中使用了相同的表单,除了这里,它确实起作用.
I'm trying to get a form inside a modal. Everything after the form tag shows up, but not the actual form tag there for can't be submitted. I am using the same form in other pages and it does work except here.
AdGroups/edit.html.haml
%div(id="openModal" class="modalDialog")
%div
%a(href="#close" title="Close" class="close")
%div
= form_tag car_path, :url => {:controller => 'cars', :action => 'create'}, :html => {:multipart => true,:id =>'car-form'} do |f|
%div(class="control-group")
= label_tag "Year"
%br
= text_field_tag "year"
%br
%div(class="control-group")
= label_tag "make"
%br
%select{ :name => "make", :class => "chosen" }
- @makes.each do |m|
%option{:value => m.id}= "#{m.name}"
%br
%div(class="control-group")
= label_tag "Model"
%br
= text_field_tag "model"
%br
%div(class="control-group")
= label_tag "Trim"
%br
= text_field_tag "trim"
%br
%div(class="control-group")
= label_tag "Car Image(s)"
%br
= file_field_tag "files[]"
%br
= submit_tag
当我检查表单而不是表单标签时,它具有输入标签.知道为什么吗?
When I inspect the form rather than the form tag it has an input tag. Any idea why?
<div class="modalDialog" id="openModal">
<div>
<a class="close" href="#close" title="Close"></a>
<div></div>
<input name="utf8" type="hidden" value="✓"><input type="hidden" name="authenticity_token" value="fc2o2n0JJlcMISfYQACsF0mNSrVkKnoa37eF2dDrGPPIu9CnJVVaNFz3drg8dAoOf1pm>
推荐答案
这可能需要几次尝试...
This might take a few tries...
看来您的form_tag
可能是错误的.试试:
It looks like your form_tag
might be wrong. Try:
= form_tag cars_path, multipart: true, id: 'car-form' do
您可以尝试这样做吗( )(以查看是否可以显示空白表格)
Can you try doing just this (to see if you can get an empty form to render):
#openModal.modalDialog
= form_tag cars_path, multipart: true, id: 'car-form' do
foo
确保您使用的是cars_path
而不是car_path
.
Make sure you're using cars_path
and not car_path
.
这篇关于表单标签未显示在haml文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!