mlibrary / heliotrope

Codebase for Fulcrum, a Samvera-based digital publishing platform built by the University of Michigan Library

Home Page:https://fulcrum.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Monograph required fields not enforced

conorom opened this issue · comments

We've decided that some of our custom fields should be required, but they are not being enforced by the JS that decides to allow the form to submit (represented by the green tick next to "Describe your work").

This is because the input elements in views/monographs/edit_fields do not have required: true or, pulling from the form, f.object.required?(key) on them.

https://github.com/samvera/hyrax/blob/54b8692e2d77721f81c53a3b9552eb5e2f564c35/app/assets/javascripts/hyrax/save_work/required_fields.es6#L20
https://github.com/samvera/hyrax/blob/694ed1938fd95abeb39b33d0a301f7cf2c272a92/app/views/records/edit_fields/_description.html.erb#L2

required? links to required_fields set in MonographForm

https://github.com/samvera/hydra-editor/blob/2e052d547379fd3b223d75610e6129bf4b178b28/app/forms/hydra_editor/form.rb#L19

  • set the required values on the custom required elements
  • (maybe) add tests for views/monographs/edit_fields.rb like Hyrax does (a simplified version of the spec from the link below with definite cardinality and required status for each custom edit field)

https://github.com/samvera/hyrax/blob/42d3a7b1c30fb9db289fbaa5b30e9828434d9985/spec/views/records/edit_fields/_description.html.erb_spec.rb

closed here:

#1829