0

我有一個頁面以表單開始。在該表單中,我呈現另一個稱爲信息的頁面。在這個渲染裏面,我有另一個模態渲染。這種模式是另一種形式。所以在這一點上,我有一個嵌套的形式。這在除IE9以外的所有瀏覽器中都很適用。我認爲IE9試圖做的是看到第二個表單何時結束,並且它也結束了第一個表單,所以嵌套表單之後的所有內容都被搞砸了。 有沒有人遇到過這個問題?你如何解決它?IE9與haml嵌套simple_form_for

父文件(表格):

= simple_form_for @form do |f| 
    #the_form 
     = render 'information', :f => f 

     .buttons 
      %input{:name => "submit", :type => "submit", :value => "SUBMIT"} 
      %input{:name => "cancel", :type => "submit", :value => "Cancel"} 

渲染信息文件:

#information 
    %fieldset 
     %legend 
      Form Title 
     = f.input :form_id, :url => form_name_path, :label => 'Field Name' 
     = render 'modal' 
    (the rest of the code here breaks)... 

渲染樣式文件:

.modal.hide.fade 
    .modalBox 
     %h3 
      New Form Name 
      %a{href: "#", class: "x", title: "Close" : 'data-dismiss' => "modal"} 
     .diagRepeater 
     .modal-body 
      = simple_form_for Form.new, :url => {:controller => :form, :action => :modal_create} do |o| 
       =o.input :name, :label => 'Name', :required => true 
       =o.input :form_id, :as => :hidden 

這是我看到的問題這最後文件。如果我註釋掉simple_form_for,它就會很好。如果我離開它,它會打破錶格的其餘部分。

+1

HTML不允許嵌套形式。它*可能*在某些瀏覽器(具有不同的行爲)下工作,但它不應該。請參閱:http://stackoverflow.com/questions/379610/can-you-nest-html-forms – Substantial 2014-10-08 23:48:45

回答

2

HTML不支持嵌套形式。 您可以在一個頁面中有多個表單,但不應該嵌套。 正如你所說:這項工作在所有瀏覽器中對我來說都很棒,這是奇蹟,因爲'你甚至會遇到問題,使它在同一瀏覽器的不同版本中工作',所以請避免使用它。

的Webkit解釋爲什麼HTML不支持嵌套形式

bool HTMLParser::formCreateErrorCheck(Token* t, RefPtr<Node>& result) 
{ 
    // Only create a new form if we're not already inside one. 
    // This is consistent with other browsers' behavior. 
    if (!m_currentFormElement) { 
     m_currentFormElement = new HTMLFormElement(formTag, m_document); 
     result = m_currentFormElement; 
     pCloserCreateErrorCheck(t, result); 
    } 
    return false; 
}