Skip to content

Commit

Permalink
fix adding new rows to the subform
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed Oct 22, 2024
1 parent 672ecca commit 4fff0c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/active_scaffold_overrides/edit_associated.js.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%
subform_id = sub_form_list_id(:association => @column.name, :id => @parent_record.id || generated_id(@parent_record) || 99999999999)
subform_id = sub_form_list_id(association: @column.name, tab_id: (params[:value] if params[:tabbed_by]), id: @parent_record.id || generated_id(@parent_record) || 99999999999)
associated_form = render :partial => "form_association_record", :object => @record, :locals => {:scope => @scope, :parent_record => @parent_record, :column => @column, :locked => @record.new_record? && @column.association.singular?}
options = {:singular => false}
if @column.association.singular?
Expand Down
4 changes: 3 additions & 1 deletion lib/active_scaffold/actions/subform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def do_edit_associated
@column = active_scaffold_config.columns[params[:child_association]]

@record = find_associated_record if params[:associated_id]
@record ||= build_associated(@column.association, @parent_record)
@record ||= build_associated(@column.association, @parent_record) do |blank_record|
blank_record.send("#{params[:tabbed_by]}=", params[:value]) if params[:tabbed_by] && params[:value]
end
end

def find_associated_record
Expand Down

0 comments on commit 4fff0c6

Please sign in to comment.