Thanks uberuser, you give me good start point. Here is next step. This is just for one country approach. That will replace the city textfield with select. Just fill your city list to _uc_city_list() method. Also the select can be populated from database.
<?php
function uc_city_form_alter($form_id, &$form) {
if($form_id == "uc_cart_checkout_form") {
if (uc_address_field_enabled('city'))
{
$form['panes']['delivery']['delivery_city'] = array(
'#type' => 'select',
'#title' => t('City'),
'#options' => _uc_city_list() ,
);
$form['panes']['billing']['billing_city'] = array(
'#type' => 'select',
'#title' => t('City'),
'#options' => _uc_city_list() ,
);
}
}
}
function _uc_city_list()
{
$options = array();
/* sample for populating form database
$result = db_query("SELECT city_id,city_name FROM {uc_cities}");
while ($city = db_fetch_array($result)) {
$options[$city['city_name']] = $city['city_name'];
}
*/
$options = array(
"Test1City" => "Test1City",
"Test2City" => "Test2City",
);
return $options;
}
?>


Joined: 01/23/2008