Skip to content

Commit

Permalink
Fix multiple custom field groups on new entity creation
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleylhs committed Aug 20, 2024
1 parent 7dc8dfa commit 9ab7032
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def versions
#----------------------------------------------------------------------------
def field_group
if @tag = Tag.find_by_name(params[:tag].strip)
if @field_group = FieldGroup.find_by_tag_id_and_klass_name(@tag.id, klass.to_s)
if @field_groups = FieldGroup.where(tag_id: @tag.id, klass_name: klass.to_s)
@asset = klass.find_by_id(params[:asset_id]) || klass.new
render('fields/group') && return
end
Expand Down
4 changes: 3 additions & 1 deletion app/views/fields/group.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= simple_fields_for(@asset) do |f| %>
$('#field_groups').append('<%= j render(partial: 'fields/group', locals: {f: f, field_group: @field_group, fields: @field_group.fields}) %>')
<% @field_groups.each do |field_group| %>
$('#field_groups').append('<%= j render(partial: 'fields/group', locals: {f: f, field_group: field_group, fields: field_group.fields}) %>')
<% end %>
<% end %>

0 comments on commit 9ab7032

Please sign in to comment.