Module: Hyrax::Forms

Defined in:
app/forms/hyrax/forms.rb,
app/forms/hyrax/forms/lease.rb,
app/forms/hyrax/forms/embargo.rb,
app/forms/hyrax/forms/work_form.rb,
app/forms/hyrax/forms/permission.rb,
app/forms/hyrax/forms/file_set_form.rb,
app/forms/hyrax/forms/resource_form.rb,
app/forms/hyrax/forms/admin_set_form.rb,
app/forms/hyrax/forms/batch_edit_form.rb,
app/forms/hyrax/forms/collection_form.rb,
app/forms/hyrax/forms/work_lease_form.rb,
app/forms/hyrax/forms/admin/appearance.rb,
app/forms/hyrax/forms/pcdm_object_form.rb,
app/forms/hyrax/forms/batch_upload_form.rb,
app/forms/hyrax/forms/work_embargo_form.rb,
app/forms/hyrax/forms/file_set_edit_form.rb,
app/forms/hyrax/forms/pcdm_collection_form.rb,
app/forms/hyrax/forms/workflow_action_form.rb,
app/forms/hyrax/forms/administrative_set_form.rb,
app/forms/hyrax/forms/permission_template_form.rb,
app/forms/hyrax/forms/resource_batch_edit_form.rb,
app/forms/hyrax/forms/admin/collection_type_form.rb,
app/forms/hyrax/forms/widgets/admin_set_visibility.rb,
app/forms/hyrax/forms/workflow_responsibility_form.rb,
app/forms/hyrax/forms/dashboard/nest_collection_form.rb,
app/forms/hyrax/forms/failed_submission_form_wrapper.rb,
app/forms/hyrax/forms/widgets/admin_set_embargo_period.rb,
app/forms/hyrax/forms/admin/collection_type_participant_form.rb

Defined Under Namespace

Modules: Admin, Dashboard, Widgets Classes: AdminSetForm, AdministrativeSetForm, BatchEditForm, BatchUploadForm, CollectionForm, Embargo, FailedSubmissionFormWrapper, FileSetEditForm, FileSetForm, Lease, PcdmCollectionForm, PcdmObjectForm, Permission, PermissionTemplateForm, ResourceBatchEditForm, ResourceForm, WorkEmbargoForm, WorkForm, WorkLeaseForm, WorkflowActionForm, WorkflowResponsibilityForm

Class Method Summary collapse

Class Method Details

.PcdmObjectForm(work_class) ⇒ Object

Examples:

defining a form class using HydraEditor-like configuration

class MonographForm < Hyrax::Forms::PcdmObjectForm(Monograph)
  self.required_fields = [:title, :creator, :rights_statement]
  # other WorkForm-like configuration here
end


13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/forms/hyrax/forms.rb', line 13

def self.PcdmObjectForm(work_class) # rubocop:disable Naming/MethodName
  Class.new(Hyrax::Forms::PcdmObjectForm) do
    self.model_class = work_class

    ##
    # @return [String]
    def self.inspect
      return "Hyrax::Forms::PcdmObjectForm(#{model_class})" if name.blank?
      super
    end
  end
end

.ResourceForm(model_class) ⇒ Object

Returns the form class associated with a given model.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/forms/hyrax/forms.rb', line 30

def self.ResourceForm(model_class) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Naming/MethodName
  @resource_forms ||= {}.compare_by_identity
  @resource_forms[model_class] ||=
    # +#respond_to?+ needs to be used here, not +#try+, because Dry::Types
    # overrides the latter??
    if model_class.respond_to?(:pcdm_collection?) && model_class.pcdm_collection?
      if model_class <= Hyrax::AdministrativeSet
        Hyrax.config.administrative_set_form
      else
        Hyrax.config.pcdm_collection_form
      end
    elsif model_class.respond_to?(:pcdm_object?) && model_class.pcdm_object?
      if model_class.respond_to?(:file_set?) && model_class.file_set?
        Hyrax.config.file_set_form
      else
        Hyrax.config.pcdm_object_form_builder.call(model_class)
      end
    else
      Hyrax::Forms::ResourceForm
    end
end