Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting a form(tastic) into a three-column layout

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!

like image 419
Robert Brandin Avatar asked Nov 06 '22 04:11

Robert Brandin


1 Answers

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.

like image 137
Robert Brandin Avatar answered Nov 09 '22 04:11

Robert Brandin