我试图将相关的属性归入“杜布尔地区”,将其归入一个表格。 投入组:
<%= semantic_form_for MyModel.new do |f| %>
<%= f.inputs Advanced do %>
<%= f.input :name %>
<%= f.inputs Min/Max , class: doublefield do %>
<%= f.input :min %>
<%= f.input :max %>
<% end %>
<%= f.inputs Zip/Place , class: doublefield do %>
<%= f.input :zip %>
<%= f.input :place %>
<% end %>
<% end %>
<% end %>
然而,这产生了这样的标志(不可否认的标志):
<form accept-charset="UTF-8" action="my_model" class="formtastic" id="new_my_model" method="post" novalidate="novalidate">
<fieldset class="inputs">
<ol>
<li class="string input optional stringish" id="my_model_name_input">
...
</li>
<li class="input">
<fieldset class="doublefield">
...
</fieldset>
</li>
<fieldset class="doublefield">
...
</fieldset>
</ol>
</fieldset>
</form>
Only the first nested fieldset in the fieldset gets surrounded by the <li>
tag, the others are just rendered as <fieldset>
which leads to invalid markup (<fieldset>
as direct child of <ol>
is not allowed). This isn t just ugly but also makes it hard to apply styles to the form.
在我的研究中,我对关于这一问题的一些评论感到困惑,其中我说,这本可能是一个充满热情的问题,但我直到现在才找到了工作或建议。
任何想法?
FCCC/SBI/2008/INF.1。
- rails (3.2.0.beta bd4bd3f)
- formtastic (2.0.0.rc4 7d3bb2f)
- ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Full markup:
<form accept-charset="UTF-8" action="my_model" class="formtastic" id="new_my_model" method="post" novalidate="novalidate">
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="zPm0lLyT6MM4M+LI1b7c9d7NqGQM2PiT+kHsjUnfTWM="></div>
<fieldset class="inputs">
<legend><span>Advanced</span></legend>
<ol>
<li class="string input optional stringish" id="my_model_name_input">
<label class=" label" for="my_model_name">Name</label>
<input id="my_model_name" maxlength="255" name="my_model[name]" type="text">
</li>
<li class="input">
<fieldset class="doublefield">
<legend><span>Min/Max</span></legend>
<ol>
<li class="number input optional stringish" id="my_model_min_input">
<label class=" label" for="my_model_roosts_min">Min</label>
<input id="my_model_min" maxlength="4" name="my_model[min]" step="any" type="number">
</li>
<li class="number input optional stringish" id="my_model_max_input">
<label class=" label" for="my_model_max">Max</label>
<input id="my_model_roosts_max" maxlength="4" name="my_model[max]" step="any" type="number">
</li>
</ol>
</fieldset>
</li>
<fieldset class="doublefield">
<legend><span>Zip/Place</span></legend>
<ol>
<li class="string input optional stringish" id="my_model_zip_input">
<label class=" label" for="my_model_zip">Zip</label>
<input id="my_model_zip" maxlength="255" name="my_model[zip]" type="text">
</li>
<li class="string input optional stringish" id="my_model_place_input">
<label class=" label" for="my_model_place">Place</label>
<input id="my_model_place" maxlength="255" name="my_model[place]" type="text">
</li>
</ol>
</fieldset>
</ol>
</fieldset>
</div>