platform-coop-toolkit / coop-library-framework

Custom Post Type utilities for the Platform Co-op Resource Library.
https://platform.coop
Other
0 stars 2 forks source link

Blank repeater fields are not properly ignored #310

Closed jhung closed 4 years ago

jhung commented 4 years ago

Describe the bug Blank repeater fields are not properly ignored if blank. Specifically:

To Reproduce Steps to reproduce the behavior:

  1. Create a new resource.
  2. Fill in the required fields (title etc.).
  3. Add an author, and 2 blank authors.
  4. Add 2 or 3 blank editors and translators.
  5. Publish the resource.
  6. Notice that the blank values for author, editor, and translator are preserved.
  7. Notice that when viewing the resource empty authors appear in the byline.
  8. Edit the same resource.
  9. Add blank perma.cc and archive.org links.
  10. Update the resource.
  11. Notice that validation errors are produced for the fields.

Expected behavior Any empty repeater field should be ignored (i.e. not validated) and not submitted as part of the Resource metadata.

Desktop (please complete the following information):

greatislander commented 4 years ago

@jhung I think rather than removing/discarding empty fields, I'd like to resolve this by making all of these sub fields required. That way if a user adds an author/translator/editor/Perma.cc link/Internet Archive link and leaves it blank, they will be notified that it must have content. I've added some code to discard empty authors in case they exist in https://github.com/platform-coop-toolkit/coop-library/commit/d98f458. PR forthcoming.