diff --git a/app/views/branded/shared/dynamic_form/_form.html.erb b/app/views/branded/shared/dynamic_form/_form.html.erb index b452435..2909045 100644 --- a/app/views/branded/shared/dynamic_form/_form.html.erb +++ b/app/views/branded/shared/dynamic_form/_form.html.erb @@ -43,7 +43,11 @@ <% if prop['items']['type'] == 'object' && prop['items']['schema_id'].present? %> <% unless classname == "research_output" %> <% sub_schema = @schemas.find_by(id: prop['items']['schema_id']) %> - <% values = dmp_fragments.where(madmp_schema_id: sub_schema.id, parent_id: fragment.id) unless dmp_fragments.empty? %> + <% p fragment %> + <% values = dmp_fragments.joins(:madmp_schema).where( + parent_id: fragment.id, + madmp_schemas: { classname: sub_schema.classname } + ) unless dmp_fragments.empty? %> <%= render(partial: 'shared/dynamic_form/fields/complex_multiple_field', locals: { field_values: values, readonly: readonly, @@ -80,9 +84,10 @@ <%= label %> <% sub_schema = @schemas.find_by(id: prop["schema_id"]) - sub_fragment = dmp_fragments.find_by(madmp_schema_id: sub_schema.id, parent_id: fragment.id) unless dmp_fragments.empty? - # TODO : SINGLE SUB FRAGMENT SAVING - #sub_fragment = dmp_fragments[sub_schema.id].find { |f| f.id == value["dbid"] } unless value.nil? + sub_fragment = dmp_fragments.joins(:madmp_schema).find_by( + parent_id: fragment.id, + madmp_schemas: { classname: sub_schema.classname } + ) unless dmp_fragments.empty? %> <%= render(partial: 'shared/dynamic_form/form', locals: { f: f,