Required. Please select your country.
I am trying to display "Required. Please select your country.", or more simply "Required.", as a placeholder in the Country dropdown box of the Create Account form in an effort to help reduce errors pre-validation, but to no avail.
Code:
<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY . '<span class="reqd">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" title="' . ENTRY_COUNTRY_TEXT . '" placeholder="' . ENTRY_COUNTRY_TEXT . '" required' . ($flag_show_pulldown_states == true ? 'onchange="update_zone(this.form);"' : '')); ?>
wrt the colour highlighting above, green works, but red and orange seem to have no affect.
Now I have the desired text defined in two places in \151\includes\languages\MyTemplate\english.php
Code:
define('ENTRY_COUNTRY_TEXT', 'Required. Please select your Country');
and
Code:
define('PULL_DOWN_DEFAULT', 'Required. Please select your country');
where the latter puts the required text at the top of the dropdown, as per includes\functions\html_output.php, ie
Code:
/*
* Creates a pull-down list of countries
*/
function zen_get_country_list($name, $selected = '', $parameters = '') {
$countriesAtTopOfList = array();
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = zen_get_countries();
// Set some default entries at top of list:
if (STORE_COUNTRY != SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY) $countriesAtTopOfList[] = SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
$countriesAtTopOfList[] = STORE_COUNTRY;
// IF YOU WANT TO ADD MORE DEFAULTS TO THE TOP OF THIS LIST, SIMPLY ENTER THEIR NUMBERS HERE.
// Duplicate more lines as needed
// Example: Canada is 108, so use 108 as shown:
//$countriesAtTopOfList[] = 108;
//process array of top-of-list entries:
foreach ($countriesAtTopOfList as $key=>$val) {
$countries_array[] = array('id' => $val, 'text' => zen_get_country_name($val));
}
// now add anything not in the defaults list:
for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
$alreadyInList = FALSE;
foreach($countriesAtTopOfList as $key=>$val) {
if ($countries[$i]['countries_id'] == $val)
{
// If you don't want to exclude entries already at the top of the list, comment out this next line:
$alreadyInList = TRUE;
continue;
}
}
if (!$alreadyInList) $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}
return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
}
As a comparison, I can display "Please select or type your State below" within the State dropdown box of the Create Account form, which is defined in \151\includes\languages\MyTemplate\english.php as:
Code:
define('TYPE_BELOW', 'Please select or type your State below ...');
However, this text is inserted by includes\functions\functions_general.php, ie
Code:
/**
* return an array with country names and matching zones to be used in pulldown menus
*/
function zen_prepare_country_zones_pull_down($country_id = '') {
// preset the width of the drop-down for Netscape
$pre = '';
if ( (!zen_browser_detect('MSIE')) && (zen_browser_detect('Mozilla/4')) ) {
for ($i=0; $i<45; $i++) $pre .= ' ';
}
$zones = zen_get_country_zones($country_id);
if (sizeof($zones) > 0) {
$zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));
$zones = array_merge($zones_select, $zones);
} else {
$zones = array(array('id' => '', 'text' => TYPE_BELOW));
// create dummy options for Netscape to preset the height of the drop-down
if ( (!zen_browser_detect('MSIE')) && (zen_browser_detect('Mozilla/4')) ) {
for ($i=0; $i<9; $i++) {
$zones[] = array('id' => '', 'text' => $pre);
}
}
}
return $zones;
}
PLEASE_SELECT is also defined in \151\includes\languages\MyTemplate\english.php as
Code:
define('PLEASE_SELECT', 'Please select ...');
Help greatly appreciated.
Re: Required. Please select your country.
I dont think the drop down list can works with placeholder. You have to change the languages for the drop down list.
Re: Required. Please select your country.
Thanks. Yes I know placeholders per se do not work with dropdowns, so what I am trying to do is emulate the way text is inserted into the State field.
My other question is how can the State text be styled. ATM the State text is rendered black, but I want it to display grey (ie color:#666;).