Class: Hyrax::Forms::AdminSetForm

Inherits:
CollectionForm show all
Defined in:
app/forms/hyrax/forms/admin_set_form.rb

Instance Attribute Summary

Attributes inherited from CollectionForm

#scope

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CollectionForm

#banner_info, build_permitted_params, #display_additional_fields?, #initialize, #list_child_collections, #list_parent_collections, #logo_info, #primary_terms, #secondary_terms, #select_files

Constructor Details

This class inherits a constructor from Hyrax::Forms::CollectionForm

Class Method Details

.multiple?(_term) ⇒ Boolean

This determines whether the allowed parameters are single or multiple. By default it delegates to the model.

Returns:

  • (Boolean)


29
30
31
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 29

def multiple?(_term)
  false
end

.sanitize_params(form_params) ⇒ Object

Overriden to cast ‘title’ and ‘description’ to an array



34
35
36
37
38
39
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 34

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

Instance Method Details

#[](key) ⇒ Object

Cast any array values on the model to scalars.



9
10
11
12
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 9

def [](key)
  return super if key == :thumbnail_id
  super.first
end

#permission_templateObject



14
15
16
17
18
19
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 14

def permission_template
  @permission_template ||= begin
                             template_model = PermissionTemplate.find_or_create_by(source_id: model.id)
                             PermissionTemplateForm.new(template_model)
                           end
end

#thumbnail_titleObject



21
22
23
24
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 21

def thumbnail_title
  return unless model.thumbnail
  model.thumbnail.title.first
end