app/forms/hyrax/forms/collection_form.rb in hyrax-5.0.0.rc2 vs app/forms/hyrax/forms/collection_form.rb in hyrax-5.0.0.rc3

- old
+ new

@@ -33,10 +33,16 @@ def can?(*args) current_ability.can?(*args) end end + # This describes the parameters we are expecting to receive from the client + # @return [Array] a list of parameters used by sanitize_params + def self.build_permitted_params + super + [{ based_near_attributes: [:id, :_destroy] }] + end + # @param model [::Collection] the collection model that backs this form # @param current_ability [Ability] the capabilities of the current user # @param repository [Blacklight::Solr::Repository] the solr repository def initialize(model, current_ability, repository) super(model) @@ -119,9 +125,22 @@ collection.member_of_collections end def list_child_collections collection_member_service.available_member_subcollections.documents + end + + protected + + def initialize_field(key) + # rubocop:disable Lint/AssignmentInCondition + if class_name = model_class.properties[key.to_s].try(:class_name) + # Initialize linked properties such as based_near + self[key] += [class_name.new] + else + super + end + # rubocop:enable Lint/AssignmentInCondition end private def all_files_with_access