ruby-on-rails – 将表单(tastic)拆分为三列布局

我对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"

在此先感谢您的帮助!

最佳答案 事实证明,当我发布这个问题并且没有想到格子里的帮手时,我处于一些疯狂的阴霾中.例如:


= semantic_form_for @something do |f|
  .grid_4
    # Part 1 of form
  .grid_4
    # Part 2 of form
  .grid_4
    # Part 3 of form

这给了我一个很好的分裂大嵌套形式.

点赞