Bug 31497 - Quick add: mandatory fields save as empty when not filled in before first save attempt
Summary: Quick add: mandatory fields save as empty when not filled in before first sav...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P3 major (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-31 13:08 UTC by Koha Team University Lyon 3
Modified: 2022-11-25 00:05 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.07, 21.11.14


Attachments
Bug 31497: Prevent ID clash on quick add fields (3.12 KB, patch)
2022-09-13 12:22 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31497: Prevent ID clash on quick add fields (3.17 KB, patch)
2022-09-13 18:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 31497: Prevent ID clash on quick add fields (3.22 KB, patch)
2022-09-13 20:29 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 31497: (follow-up) Expand ID suffix, fix password2, remove debug (2.46 KB, patch)
2022-09-16 11:07 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31497: Prevent ID clash on quick add fields (3.28 KB, patch)
2022-09-20 21:38 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 31497: (follow-up) Expand ID suffix, fix password2, remove debug (2.52 KB, patch)
2022-09-20 21:38 UTC, Chris Cormack
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Koha Team University Lyon 3 2022-08-31 13:08:24 UTC
After filling it in, the 2nd attempt is not blocked, the validation can be done, but it seems that the field is cleared just before submission.

Olivier Crouzet
Comment 1 Katrin Fischer 2022-09-11 14:08:20 UTC
This bug is also present in current master (development branch).

To test:
* Go to patrons module 
* Click on Quick add new patron (I chose Patron as category)
* On sample database these fields are marked as mandatory:
  * Surname
  * Cardnumber
  * Library
  * Category
* Fill in Surname, leave cardnumber empty
* Save - mandatory message is shown
* Fill in cardnumber - save
* The patron is saved
* BUT: cardnumber is empty!

Updating to major for data loss.
Comment 2 Nick Clemens 2022-09-13 12:22:26 UTC
Created attachment 140568 [details] [review]
Bug 31497: Prevent ID clash on quick add fields

The quick add clones the original fields, including ids. This can cause some clash when
other JS is running on the page.

This patch updates the ids of the fields before adding to the form, which prevents bad
copying/clearing of fields

To test:
* Go to patrons module
* Click on Quick add new patron (I chose Patron as category)
* On sample database these fields are marked as mandatory:
  * Surname
  * Cardnumber
  * Library
  * Category
* Fill in Surname, leave cardnumber empty
* Save - mandatory message is shown
* Fill in cardnumber - save
* The patron is saved
* BUT: cardnumber is empty!
APPLY PATCH
* Repeat plan above
* Cardnumber is correctly saved
Comment 3 David Nind 2022-09-13 18:48:58 UTC
Created attachment 140603 [details] [review]
Bug 31497: Prevent ID clash on quick add fields

The quick add clones the original fields, including ids. This can cause some clash when
other JS is running on the page.

This patch updates the ids of the fields before adding to the form, which prevents bad
copying/clearing of fields

To test:
* Go to patrons module
* Click on Quick add new patron (I chose Patron as category)
* On sample database these fields are marked as mandatory:
  * Surname
  * Cardnumber
  * Library
  * Category
* Fill in Surname, leave cardnumber empty
* Save - mandatory message is shown
* Fill in cardnumber - save
* The patron is saved
* BUT: cardnumber is empty!
APPLY PATCH
* Repeat plan above
* Cardnumber is correctly saved

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 ByWater Sandboxes 2022-09-13 20:29:18 UTC
Created attachment 140606 [details] [review]
Bug 31497: Prevent ID clash on quick add fields

The quick add clones the original fields, including ids. This can cause some clash when
other JS is running on the page.

This patch updates the ids of the fields before adding to the form, which prevents bad
copying/clearing of fields

To test:
* Go to patrons module
* Click on Quick add new patron (I chose Patron as category)
* On sample database these fields are marked as mandatory:
  * Surname
  * Cardnumber
  * Library
  * Category
* Fill in Surname, leave cardnumber empty
* Save - mandatory message is shown
* Fill in cardnumber - save
* The patron is saved
* BUT: cardnumber is empty!
APPLY PATCH
* Repeat plan above
* Cardnumber is correctly saved

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 5 Marcel de Rooy 2022-09-16 09:37:08 UTC
child_input.attr("id") + "_qa"
Please clarify :)

+                           console.log( orig_input_id);
Debug ?
Comment 6 Marcel de Rooy 2022-09-16 09:37:53 UTC
(In reply to Marcel de Rooy from comment #5)
> child_input.attr("id") + "_qa"
> Please clarify :)
> 
If you want to prevent clashing, wouldnt you need a more robust suffix?
Comment 7 Nick Clemens 2022-09-16 11:07:13 UTC
Created attachment 140703 [details] [review]
Bug 31497: (follow-up) Expand ID suffix, fix password2, remove debug
Comment 8 Chris Cormack 2022-09-20 21:38:27 UTC
Created attachment 140808 [details] [review]
Bug 31497: Prevent ID clash on quick add fields

The quick add clones the original fields, including ids. This can cause some clash when
other JS is running on the page.

This patch updates the ids of the fields before adding to the form, which prevents bad
copying/clearing of fields

To test:
* Go to patrons module
* Click on Quick add new patron (I chose Patron as category)
* On sample database these fields are marked as mandatory:
  * Surname
  * Cardnumber
  * Library
  * Category
* Fill in Surname, leave cardnumber empty
* Save - mandatory message is shown
* Fill in cardnumber - save
* The patron is saved
* BUT: cardnumber is empty!
APPLY PATCH
* Repeat plan above
* Cardnumber is correctly saved

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 9 Chris Cormack 2022-09-20 21:38:54 UTC
Created attachment 140809 [details] [review]
Bug 31497: (follow-up) Expand ID suffix, fix password2, remove debug

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 10 Tomás Cohen Arazi 2022-09-22 11:25:08 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 11 Lucas Gass 2022-10-31 22:33:53 UTC
Backported to 22.05.x for upcoming 22.05.07 release
Comment 12 Arthur Suzuki 2022-11-14 16:30:39 UTC
applied to 21.11 for 21.11.14
Comment 13 Victor Grousset/tuxayo 2022-11-25 00:05:17 UTC
21.05.x not affected, no backport.

Nothing to document, marking resolved.