From c3d758a016fd45f2e298b34e42728f6a37c1c7bd Mon Sep 17 00:00:00 2001 From: Haneef <298208+haneef95@users.noreply.github.com> Date: Thu, 25 May 2023 15:58:29 +0100 Subject: [PATCH] Fixed issue where by it was referring to attrReadyMaxFieldId. And $maxField.hasClass('gfield_radio') . --- .../gpnf-limit-entry-min-max-from-field.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gp-nested-forms/gpnf-limit-entry-min-max-from-field.php b/gp-nested-forms/gpnf-limit-entry-min-max-from-field.php index 7eced271c..3eb64fe02 100644 --- a/gp-nested-forms/gpnf-limit-entry-min-max-from-field.php +++ b/gp-nested-forms/gpnf-limit-entry-min-max-from-field.php @@ -131,8 +131,8 @@ public function output_script() { self.init = function () { - var attrReadyMaxFieldId = self.maxFieldId.replace( '.', '_' ); - var maxFieldId = 'input_' + self.parentFormId + '_' + attrReadyMaxFieldId; + //var attrReadyMaxFieldId = self.maxFieldId.replace( '.', '_' ); + var maxFieldId = 'input_' + self.parentFormId + '_' + self.maxFieldId; // GF uses "1" for the input index in the HTML id attribute for Single Product fields. Weird. var $maxField = $( '#input_' + self.parentFormId + '_' + parseInt( self.maxFieldId ) ); @@ -146,7 +146,13 @@ public function output_script() { } var $maxField = $( '#' + maxFieldId ); - var value = parseInt($maxField.val()); + + // Getting values of Radio Choices works slightly differently + if ( $maxField.hasClass('gfield_radio') ){ + var value = parseInt($("input[id^='choice_" + self.parentFormId + "_" + self.maxFieldId + "_']:checked").val()); + } else { + var value = parseInt($maxField.val()); + } return value ? value : self.defaultMax; }); @@ -215,4 +221,4 @@ public function should_field_be_validated( $form, $field ) { return true; } -} +} \ No newline at end of file