5

I'm quite new to Rails, so please excuse any wildly inaccurate terminology. First, some context: I'm building a sample tracking web app for a small analytical lab. It would be particularly slick to be able to split up a batch submission form into three columns. A batch is associated with several tests in column 1, batch information is entered into column 2, and individual samples are named in column 3. Ideally, there'd be a nice big submit button at the bottom of column 3 that pushes the whole mess through.

I am using 960 (12 column) for CSS and formtastic for form generation. My first inclination is to set up the columns by way of three divs and to split the form discretely into each div, however, I'm unsure how to split up a form into divs while maintaining what I'll hackishly call a persistence of data across all columns. Should I even be using divs? Here's some code show my general gist:


.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"

Thanks in advance for any help!

2 Answers2

2

Turns out I was in some crazy haze when I posted this question and didn't think to grid inside of the formtastic helper. For example:


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

Which gives me a nicely split up big nested form.

0

Sammy is your answer. I have used it in one of my projects and I must say it is simple and works.

Syed Aslam
  • 8,707
  • 5
  • 40
  • 54
  • 1
    Ahhhh, turns out your answer was right and my question was wrong. I was going for a long, nested form and subsequently should've put my grids inside of the semantic_form_for. I will definitely read up on sammy though, thanks! – Robert Brandin Jan 18 '11 at 22:06
  • If my answer was right, you might consider accepting it or giving a +1 atleast! – Syed Aslam Jan 20 '11 at 11:34
  • Once I have the required rep I'll shoot you a +1. Thanks! – Robert Brandin Jan 20 '11 at 17:09