I'm using simple_nested_form_for
to build a form with nested fields. Fields are added dynamically
When rendering the form with errors (via create
) the nested fields go wrong.
The same nested fields are shown multiple times and with the wrong index values in the name
elements.
For example the FormBuilder
index
in the nested field is initially a random number such as 1454793731550
. After re-rendering they simply become normal increments 0-n
.
Why is the FormBuilder
index
initially a random number?
Any suggestion what could be going on here?
def new
@transaction = current_company.transactions.build
@transaction.subtransactions.build
end
def create
@transaction = current_company.transactions.new(transaction_params)
if @transaction.save
redirect_to dashboard_url
else
@transaction.subtransactions.build
render :action => 'new'
end