[interchange] Allow country_select widget use with Autofill programs

Greg Hanson interchange-cvs at icdevgroup.org
Tue Feb 22 00:34:56 UTC 2011

commit 07f1fd554959a04e2668776ed3c689205b7761fd
Author: Greg Hanson <greg at perusion.com>
Date:   Mon Feb 21 19:30:06 2011 -0500

    Allow country_select widget use with Autofill programs
    The country_select widget creates a javascript function depending on
    the country selected, in order to display the proper "state set" for
    the chosen country using a select widget with the name
    A problem arises however when auto form fillers are used because
    instead of populating the value of the hidden "state" input field as
    you would expect, they populate the value of the created select
    widget named "state_cs_in".  To the user, it appears that the proper
    state has been selected, however at this point only the
    "state_cs_in" has been set. Because a javascript function to set the
    "state" value to the chosen "state_cs_in" selected value is never
    triggered with an "onChange" when the "auto-fill" is used, the value
    never gets set, and the user submits the form and receives a
    State/Province /('' not a two-letter state code)/
    error message.
    A simple solution for this problem is to add code to the
    mv_form_profile that performs the work if "state_cs_in" has been
    changed but "state" has not.

 dist/standard/pages/ord/billing.html  |    6 ++++++
 dist/standard/pages/ord/shipping.html |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/dist/standard/pages/ord/billing.html b/dist/standard/pages/ord/billing.html
index 5a4806a..80645a6 100644
--- a/dist/standard/pages/ord/billing.html
+++ b/dist/standard/pages/ord/billing.html
@@ -103,6 +103,12 @@ function do_address (form, clear) {
+	[calc]
+		if ($CGI->{b_state_cs_in} && !$CGI->{b_state}){
+			$CGI->{b_state} = $CGI->{b_state_cs_in};
+		}
+		return;
+	[/calc]
 	[if session logged_in]
 		[tmp tmp_save_billing][userdb function=set_billing nickname=default][/tmp]
diff --git a/dist/standard/pages/ord/shipping.html b/dist/standard/pages/ord/shipping.html
index 055d134..a810f75 100644
--- a/dist/standard/pages/ord/shipping.html
+++ b/dist/standard/pages/ord/shipping.html
@@ -61,6 +61,12 @@ ui_template_name: noleft
 [set Check_shipping]
+	[calc]
+		if ($CGI->{state_cs_in} && !$CGI->{state}){
+			$CGI->{state} = $CGI->{state_cs_in};
+		}
+		return;
+	[/calc]

More information about the interchange-cvs mailing list