Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow form pulldown to pre-select multiple values if array is passed containing desired defaults #15

Open
wants to merge 2 commits into from

1 participant

@randomecho

In cases where the store may want or need to show multiple options in a SELECT form input item, this will allow an array of default values to be passed and pre-selected.

Example:

$comic_publishers[] = array("id" => 'marvel', "text" => 'Marvel');
$comic_publishers[] = array("id" => 'dc', "text" => 'DC');
$comic_publishers[] = array("id" => 'darkhorse', "text" => 'Dark Horse');
$comic_publishers[] = array("id" => 'image', "text" => 'Image Comics');
$comic_publishers[] = array("id" => 'idw', "text" => 'IDW');

$fave_publishers = array('marvel', 'darkhorse', 'image');

echo tep_draw_pull_down_menu('house_of_comics', $comic_publishers, $fave_publishers, 'size="5" multiple');

The above will show a SELECT input field of multiple options, five items showing before scrolling, where "Marvel", "Dark Horse" and "Image Comics" will be already selected.

@randomecho

@haradlpdl Do you have any feedback or notes on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 catalog/admin/includes/functions/general.php
@@ -471,7 +471,7 @@ function tep_get_zone_code($country, $zone, $def_state) {
$state_prov_values = tep_db_fetch_array($state_prov_query);
$state_prov_code = $state_prov_values['zone_code'];
}
-
+
return $state_prov_code;
}
@@ -714,8 +714,8 @@ function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
////
// Function to read in text area in admin
- function tep_cfg_textarea($text) {
- return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);
+ function tep_cfg_textarea($text, $key = '') {
+ return tep_draw_textarea_field('configuration['.$key.']', false, 35, 5, $text);
}
function tep_cfg_get_zone_name($zone_id) {
View
2  catalog/admin/includes/functions/html_output.php
@@ -327,7 +327,7 @@ function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = ''
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
- if ($default == $values[$i]['id']) {
+ if ($default == $values[$i]['id'] || (is_array($default) && in_array($values[$i]['id'], $default))) {
$field .= ' selected="selected"';
}
View
2  catalog/includes/functions/html_output.php
@@ -309,7 +309,7 @@ function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = ''
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
- if ($default == $values[$i]['id']) {
+ if ($default == $values[$i]['id'] || (is_array($default) && in_array($values[$i]['id'], $default))) {
$field .= ' selected="selected"';
}
Something went wrong with that request. Please try again.