我对 Rails 很陌生,所以请原谅任何非常不准确的术语。首先,一些背景:我正在为一个小型分析实验室构建一个示例跟踪 Web 应用程序。能够将批量提交表单分成三列会特别巧妙。一个批次与第 1 列中的多个测试相关联,批次信息输入到第 2 列,单个样品在第 3 列中命名。理想情况下,第 3 列底部有一个漂亮的大提交按钮,可以推动整个混乱通过。
我使用 960(12 列)来生成 CSS,使用 formtastic 来生成表单。我的第一个倾向是通过三个 div 设置列并将表单离散地拆分为每个 div,但是,我不确定如何将表单拆分为 div,同时保持我称之为数据的持久性跨所有列。我什至应该使用 div 吗?这是一些代码显示我的一般要点:
.grid_4
# Test associating stuff
.grid_4
= semantic_form_for @batch do |f|
= f.inputs :name => "Batch Info" do
= f.input :sampling_date, :required => false
= f.input :experiment_name, :required => false
= f.input :notes, :as => :text
.grid_4
# The page obviously breaks without this line, but it makes the form only
# pertain to the inputs in this column.
= semantic_form_for @batch do |f|
# The sample and test association stuff will be nested forms
= f.semantic_fields_for :samples do |sample_form|
= sample_form.input :sample_name
= f.buttons do
= f.commit_button :label => "Submit batch"
提前感谢您的帮助!