snippet-library
snippet-library copied to clipboard
`gw-prevent-duplicate-selections.php`: Fixed an issue with duplicate selections logic did not work with some dynamically populated data.
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2493953931/60560?folderId=3808239
Summary
The snippet doesn't work when the dropdown field choices are not set when the form renders. If choices are populated later based on another field selection, it doesn't work. We need to ensure to re-render the logic with gppa_updated_batch_fields for updated fields.
A quick summary screencast of testing this update: https://www.loom.com/share/a668853d694b4575b0132a077eeeb00d
@saifsultanc I was waiting on a customer to reply before merging https://github.com/gravitywiz/snippet-library/pull/762 but I went ahead and merged it since it will conflict like crazy with this PR.
With the latest version of the snippet, if you put the GPPA listener inside the window.<?php echo __CLASS__; ?> = function() { and call gwDisableDuplicates accordingly on the freshed fields, I think that'll do.
@saifsultanc I was waiting on a customer to reply before merging #762 but I went ahead and merged it since it will conflict like crazy with this PR.
With the latest version of the snippet, if you put the GPPA listener inside the
window.<?php echo __CLASS__; ?> = function() {and callgwDisableDuplicatesaccordingly on the freshed fields, I think that'll do.
https://github.com/gravitywiz/snippet-library/pull/766/files#diff-ec797900697c813e11e999bf0c339c4d8ff0abf0e3c0f32d5a412a6f4e3d24bbR66-R68