app/forms/hyrax/forms/resource_form.rb in hyrax-3.0.1 vs app/forms/hyrax/forms/resource_form.rb in hyrax-3.0.2

- old
+ new

@@ -89,11 +89,16 @@ property :date_modified, readable: false property :date_uploaded, readable: false property :agreement_accepted, virtual: true, default: false, prepopulator: ->(_opts) { self.agreement_accepted = !model.new_record } - collection :permissions, virtual: true, default: [], form: Permission, prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions } + collection(:permissions, + virtual: true, + default: [], + form: Permission, + populator: :permission_populator, + prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions }) # virtual properties for embargo/lease; property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date } property :visibility_after_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_after_embargo = model.embargo&.visibility_after_embargo } property :visibility_during_embargo, virtual: true, prepopulator: ->(_opts) { self.visibility_during_embargo = model.embargo&.visibility_during_embargo } @@ -198,9 +203,14 @@ def display_additional_fields? secondary_terms.any? end private + + # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections + def permission_populator(collection:, index:, **) + Permission.new(collection[index]) + end def _form_field_definitions self.class.definitions end end