Skip to content

Commit fdaacfd

Browse files
orangewolftamsin johnson
authored and
tamsin johnson
committed
do not fall back to generic resourceform if there is a syntax error in your work_type_form object
1 parent 75312ee commit fdaacfd

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

app/forms/hyrax/forms/resource_form.rb

+15-11
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,22 @@ class << self
121121
# monograph = Monograph.new
122122
# change_set = Hyrax::Forms::ResourceForm.for(monograph)
123123
def for(resource)
124-
"#{resource.class.name}Form".constantize.new(resource)
125-
rescue NameError => _err
126-
case resource
127-
when Hyrax::AdministrativeSet
128-
Hyrax::Forms::AdministrativeSetForm.new(resource)
129-
when Hyrax::FileSet
130-
Hyrax::Forms::FileSetForm.new(resource)
131-
when Hyrax::PcdmCollection
132-
Hyrax::Forms::PcdmCollectionForm.new(resource)
124+
klass = "#{resource.class.name}Form".safe_constantize
125+
126+
if klass
127+
klass.new(resource)
133128
else
134-
# NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
135-
Hyrax::Forms::ResourceForm(resource.class).new(resource)
129+
case resource
130+
when Hyrax::AdministrativeSet
131+
Hyrax::Forms::AdministrativeSetForm.new(resource)
132+
when Hyrax::FileSet
133+
Hyrax::Forms::FileSetForm.new(resource)
134+
when Hyrax::PcdmCollection
135+
Hyrax::Forms::PcdmCollectionForm.new(resource)
136+
else
137+
# NOTE: This will create a +Hyrax::Forms::PcdmObjectForm+.
138+
Hyrax::Forms::ResourceForm(resource.class).new(resource)
139+
end
136140
end
137141
end
138142

0 commit comments

Comments
 (0)