Class: Hyrax::Forms::AdminSetForm

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CollectionForm

#primary_terms, #secondary_terms, #select_files

Constructor Details

#initialize(model) ⇒ AdminSetForm

Returns a new instance of AdminSetForm.

Parameters:



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

def initialize(model)
  super(model)
end

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)


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

def multiple?(_term)
  false
end

.sanitize_params(form_params) ⇒ Object

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



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

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.



13
14
15
16
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 13

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

#permission_templateObject



18
19
20
21
22
23
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 18

def permission_template
  @permission_template ||= begin
                             template_model = PermissionTemplate.find_by!(admin_set_id: model.id)
                             PermissionTemplateForm.new(template_model)
                           end
end