Sha256: 8530c51f2782140f736d0a6ff8e1efa6149f20009891e33250c690d1f74be0b4
Contents?: true
Size: 1.37 KB
Versions: 34
Compression:
Stored size: 1.37 KB
Contents
module Hyrax module Forms class AdminSetForm < Hyrax::Forms::CollectionForm self.model_class = AdminSet self.terms = [:title, :description, :thumbnail_id] # Cast any array values on the model to scalars. def [](key) return super if key == :thumbnail_id super.first end def permission_template @permission_template ||= begin template_model = PermissionTemplate.find_or_create_by(source_id: model.id) PermissionTemplateForm.new(template_model) end end def thumbnail_title return unless model.thumbnail model.thumbnail.title.first end class << self # This determines whether the allowed parameters are single or multiple. # By default it delegates to the model. def multiple?(_term) false end # Overriden to cast 'title' and 'description' to an array def sanitize_params(form_params) super.tap do |params| params['title'] = Array.wrap(params['title']) if params.key?('title') params['description'] = Array.wrap(params['description']) if params.key?('description') end end end private def member_work_ids model.member_ids end end end end
Version data entries
34 entries across 34 versions & 1 rubygems