If you overide _form_association.rhtml around line 14, if @record.new_record? associated << column.association.klass.new(:name => "Excellent", :score => 5) associated << column.association.klass.new(:name => "Good", :score => 4) associated << column.association.klass.new(:name => "Average", :score => 2) associated << column.association.klass.new(:name => "Poor", :score => 3) associated << column.association.klass.new(:name => "Very Poor", :score => 1) associated << column.association.klass.new(:name => "No Answer", :score => 0) associated.last.errors.clear end
This populates the various fields with some default answers, JB On 21 May, 11:46, johnnybutler7 <[email protected]> wrote: > Hi, > > I have a has_many relationship so what i would like in the subform is > say a default of 5 blank fields to enter. > > Currently we get 1 by standard so if i could have 5 as a default, i > tried a few things like the below but this doesnt work. > > def do_new(record) > super > 5.times {record.options.build} > end > > So it would be the same for edit, If i had 3 has_many records then > only 2 blank fields will be available for entering... > > Anyone done this or got a solution, > > JB --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
