need help with nested forms and habtm

Hi,

I'm currently stuck with a problem I just can't find a clever solution for. I checked every tutorial, issuetracker, API reference I could find but found nothing to "enlighten" me --> I desperately need your help :-).

My Question is: is it possible to use nested forms for habtm associations?

--> Here some more info about what I wanted to do and what failed

### Basic info ### I've got following model associations: Customer    has_many :inquiries    attr_accessible :inquiry_ids    accepts_nested_attributes_for :inquiries

Inquiry    belongs_to :customer    has_and_belongs_to_many :machines    accepts_nested_attributes_for :machines    attr_accessible :machine_ids

Machine    has_and_belongs_to_many :inquiries

I'm on Rails 2.3.5 and formtastic 0.9.7

### What I want ### I wanted to build a nested form (using formtastic + haml), so a User could enter his data and create an inquiry regarding several machines (he put into a cart in advance)

so I set up this: - semantic_form_for @customer do |form|      - form.inputs do        = form.input :companyname        = form.input :salutation, :as => :radio, :label => "Gender", :collection => [["Mister", "m"], ["Mrs.", "f"]]        = form.input :first_name        = form.input :last_name        = form.input :street        = form.input :zip        = form.input :city        = form.input :phone        = form.input :mobile        = form.input :fax        = form.input :email

     - form.inputs :for => [:inquiries, @inquiries] do |inquiry_form|        = inquiry_form.input :text, :hint => t("inquiryinfo")        - inquiry_form.inputs :for => [:machines, @machines] do

machine_form|

         = machine_form.input :id, :as => :hidden      = form.commit_button :label => t("send")

### PROBLEM ### - the form renders fine for the customer and inquiry fields --> OK! - the form renders the hidden field only for the FIRST machine in my @machines collection (and there is definitly more then 1 machine in the collection, I already checked this with array size and by outputting the machines in a for each loop)

### QUESTION ### - Did I miss some configuration? - are nested forms not usable for habtm associations??? --> if so, how could I handle my "use case" in the controller?

I'd be sooo happy I any of you could help me out with this.....I'm really lost :frowning: P.S. Sorry for my English, it's not my native tongue :slight_smile: