views:

33

answers:

1

Hey,

I'm putting together a form to create an order, where one order has many order items. I have it working so it lists all the available products with blank quantity fields, and the user can update those fields to order large amounts of each product.

I validate the numericality of the quantities in the order item model.

The only issue now though is how I show the errors from the order item model if the user enters invalid data? Currently I can only get 'order item is invalid'..

You can see my form here, I'm using haml and formtastic: http://gist.github.com/513023

Cheers!

A: 

Hi there,

I've not used Formtastic myself, but have you got:

accepts_nested_attributes_for :order_item

...in your order model?

Scott Lowe
Hey Scott, I'd seen that phrase about with reference to the semantic_fields_for option in formtastic, but hadn't understood it would also work for my slightly different implementation .. But it worked perfectly!Thanks very much!
Dan