/[drupal]/contributions/modules/payment_ach/payment_ach.theme
ViewVC logotype

Contents of /contributions/modules/payment_ach/payment_ach.theme

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Sep 21 22:45:22 2006 UTC (3 years, 2 months ago) by budda
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Initial check in of ACH Payment module for Drupal eCommerce system.
1 <?php
2 // $Id$
3
4 function theme_payment_ach_select($element) {
5 $select = '';
6 $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
7 _form_set_class($element, array('form-select'));
8 return theme('form_element', $element['#title'], '<select name="'. $element['#name'] .''. ($element['#multiple'] ? '[]' : '') .'"'. ($element['#multiple'] ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="' . $element['#id'] .'" '. $size .'>'. payment_ach_form_select_options($element) .'</select>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
9 }
10
11 function payment_ach_form_select_options($element, $choices = NULL) {
12 if (!isset($choices)) {
13 $choices = $element['#options'];
14 }
15 // array_key_exists() accommodates the rare event where $element['#value'] is NULL.
16 // isset() fails in this situation.
17 $value_valid = isset($element['#value']) || array_key_exists('#value', $element);
18 $value_is_array = is_array($element['#value']);
19 $options = '';
20 foreach ($choices as $key => $choice) {
21 if (is_array($choice)) {
22 $options .= '<optgroup label="'. $key .'">';
23 $options .= payment_ach_form_select_options($element, $choice);
24 $options .= '</optgroup>';
25 }
26 else {
27 $key = (string)$key;
28 if ($value_valid && ($element['#value'] == $key || ($value_is_array && in_array($key, $element['#value'])))) {
29 $selected = ' selected="selected"';
30 }
31 else {
32 $selected = '';
33 }
34 $options .= '<option value="'. $key .'"'. $selected .' id="cardtype-'. $key .'">'. check_plain($choice) .'</option>';
35 }
36 }
37 return $options;
38 }

  ViewVC Help
Powered by ViewVC 1.1.2