Bug 33684 - Able to save patron with empty mandatory date fields
Summary: Able to save patron with empty mandatory date fields
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-05 07:45 UTC by Emmi Takkinen
Modified: 2023-07-20 04:13 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.06,22.05.14


Attachments
Bug 33684: Make mandatory date fields required when editing a patron (1.78 KB, patch)
2023-05-09 08:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33684: Make mandatory date fields required when editing a patron (1.84 KB, patch)
2023-05-09 08:24 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 33684: Make mandatory date fields required when editing a patron (1.95 KB, patch)
2023-05-09 09:44 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2023-05-05 07:45:21 UTC
One is able to save patron without date of birth even if "dateofbirth" is set mandatory in syspref BorrowerMandatoryField. This doesn't seem to happen with other fields.

To reproduce:

1. Add "dateofbirth" to syspref BorrowerMandatoryField.
2. Add patron and leave date of birth input field empty.
3. Save.
=> Patron is saved succesfully.
Comment 1 Emmi Takkinen 2023-05-05 08:04:59 UTC
Tested this a bit and it seems that any field with flatpicker attached to it has this same problem, e.g. expiration date.
Comment 2 Jonathan Druart 2023-05-09 08:14:54 UTC
Created attachment 150823 [details] [review]
Bug 33684: Make mandatory date fields required when editing a patron

Date fields in BorrowerMandatoryField are not required by the validation
form when a new patron is added or modified.

This is because the 'required' prop does not exist on the input element
when the flatpickr instance is created.
We should either add it in the DOM directly (tt), but it will require to
do it "manually" for each date fields, or add it when we add it to the
inputs. This patch implements the second option.

Test plan:
1. Add "dateofbirth" to syspref BorrowerMandatoryField.
2. Add patron and leave date of birth input field empty.
3. Save.
=> Form is not submitted and you are asked to fill in a date of birth
Comment 3 Emmi Takkinen 2023-05-09 08:24:34 UTC
Created attachment 150826 [details] [review]
Bug 33684: Make mandatory date fields required when editing a patron

Date fields in BorrowerMandatoryField are not required by the validation
form when a new patron is added or modified.

This is because the 'required' prop does not exist on the input element
when the flatpickr instance is created.
We should either add it in the DOM directly (tt), but it will require to
do it "manually" for each date fields, or add it when we add it to the
inputs. This patch implements the second option.

Test plan:
1. Add "dateofbirth" to syspref BorrowerMandatoryField.
2. Add patron and leave date of birth input field empty.
3. Save.
=> Form is not submitted and you are asked to fill in a date of birth

Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Comment 4 Katrin Fischer 2023-05-09 09:44:26 UTC
Created attachment 150831 [details] [review]
Bug 33684: Make mandatory date fields required when editing a patron

Date fields in BorrowerMandatoryField are not required by the validation
form when a new patron is added or modified.

This is because the 'required' prop does not exist on the input element
when the flatpickr instance is created.
We should either add it in the DOM directly (tt), but it will require to
do it "manually" for each date fields, or add it when we add it to the
inputs. This patch implements the second option.

Test plan:
1. Add "dateofbirth" to syspref BorrowerMandatoryField.
2. Add patron and leave date of birth input field empty.
3. Save.
=> Form is not submitted and you are asked to fill in a date of birth

Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>

https://bugs.koha-community.org/show_bug.cgi?id=33648
Comment 5 Tomás Cohen Arazi 2023-05-10 18:28:56 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 6 Matt Blenkinsop 2023-05-15 12:42:38 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 7 Lucas Gass 2023-06-15 19:07:26 UTC
Backported to 22.05.x for upcoming 22.05.14
Comment 8 Danyon Sewell 2023-07-20 04:13:05 UTC
Not backporting to 21.11.x