diff --git a/app/forms/hyrax/pdf_form_behavior.rb b/app/forms/hyrax/pdf_form_behavior.rb index f95c6de70..cd909a56a 100644 --- a/app/forms/hyrax/pdf_form_behavior.rb +++ b/app/forms/hyrax/pdf_form_behavior.rb @@ -5,7 +5,14 @@ module PdfFormBehavior extend ActiveSupport::Concern included do + class_attribute :hidden_terms + self.terms += %i[show_pdf_viewer show_pdf_download_button] + self.hidden_terms = %i[show_pdf_viewer show_pdf_download_button] + end + + def hidden?(key) + hidden_terms.include? key.to_sym end end end diff --git a/app/views/records/edit_fields/_default.html.erb b/app/views/records/edit_fields/_default.html.erb index aa83a89c8..6a5283809 100644 --- a/app/views/records/edit_fields/_default.html.erb +++ b/app/views/records/edit_fields/_default.html.erb @@ -1,18 +1,20 @@ <%# OVERRIDE: HydraEditor 5.0.5 support dynamic labels and hints for custom worktypes %> <%# Avoid NoMethod error when rendering partial in Collection or batch edit form %> +<%# Hide unwanted fields from the form %> - <% record = f.object.model %> - <% if f.object.multiple? key %> - <%= f.input key, - as: :multi_value, - label: label_for(term: key, record_class: record.class), - hint: hint_for(term: key, record_class: record.class), - input_html: { class: 'form-control' }, - required: f.object.required?(key) %> - <% else %> - <%= f.input key, - label: label_for(term: key, record_class: record.class), - hint: hint_for(term: key, record_class: record.class), - required: f.object.required?(key) %> - <% end %> +<% return if f.object.try(:hidden?, key) == false %> +<% record = f.object.model %> +<% if f.object.multiple? key %> + <%= f.input key, + as: :multi_value, + label: label_for(term: key, record_class: record.class), + hint: hint_for(term: key, record_class: record.class), + input_html: { class: 'form-control' }, + required: f.object.required?(key) %> +<% else %> + <%= f.input key, + label: label_for(term: key, record_class: record.class), + hint: hint_for(term: key, record_class: record.class), + required: f.object.required?(key) %> +<% end %>