Thanks Carl,
Figured I'd post my results here for anyone who might be interested:
First of all, I'm a fool - because once again I've discovered that Gravity Forms is one step ahead of me (and I've only had it for about 24 hours). I can set the Address Type in the Address field to "Canadian" and it already handles all of this. Anyhow, for anyone who wants to do it for their own country, here's how you'd do it for Canada (if it wasn't already built in):
add_filter("gform_address_types", "canadian_address");
function canadian_address($address_types, $form_id) {
$address_types["canada"] = array(
"label" => "Canadian",
"country" => "Canada",
"zip_label" => "Postal Code",
"state_label" => "Province",
"states" => array(
"Alberta",
"British Columbia",
"Manitoba",
"New Brunswick",
"Newfoundland & Labrador",
"Northwest Territories",
"Nova Scotia",
"Nunavut",
"Ontario",
"Prince Edward Island",
"Quebec",
"Saskatchewan",
"Yukon")
);
return $address_types;
}
and for adding a predefined list:
add_filter("gform_predefined_choices", "add_predefined_choices_honda_models");
function add_predefined_choices_honda_models($choices) {
$choices["Honda Models"] = array(
"Accord Coupe",
"Accord Crosstour",
"Accord Sedan",
"Civic Coupe",
"Civic Sedan",
"CR-V",
"CR-Z",
"Element",
"Fit",
"Insight",
"Odyssey",
"Pilot",
"Prelude",
"Ridgeline",
"S2000"
);
return $choices;
}
So I guess this leads to a new question - is it possible to set the default state and/or address type? That way whenever I add an Address field it gets set to Address Type "Canadian" and default province "Ontario".
Posted 14 years ago on Friday December 3, 2010 |
Permalink