You are here

function _uc_ajax_admin_list_triggers in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_ajax_admin/uc_ajax_admin.module \_uc_ajax_admin_list_triggers()

Recursively builds a list of all form elements which are suitable triggers for ajax updates.

Parameters

$element: The element to check.

$list: The list being built. When complete will be an array of the form 'element_name' => 'Element title' where 'element_name' is the name of the element as would be specified for form_set_error(), and 'Element title' is a best guess at the human readable name of the element.

1 call to _uc_ajax_admin_list_triggers()
_uc_ajax_admin_checkout_trigger_options in uc_ajax_admin/uc_ajax_admin.module
Builds a hierarchical list of possible ajax triggers for the checkout form.

File

uc_ajax_admin/uc_ajax_admin.module, line 178
Configures Ajax behaviours on the Ubercart checkout page.

Code

function _uc_ajax_admin_list_triggers($element, &$list) {
  if (!empty($element['#input']) && !in_array($element['#type'], array(
    'hidden',
    'uc_address',
  ))) {
    $key = implode('][', $element['#array_parents']);
    switch ($element['#type']) {
      case 'button':
      case 'submit':
        $title = empty($element['#value']) ? $key : $element['#value'];
        break;
      default:
        $title = empty($element['#title']) ? $key : $element['#title'];
    }
    $list[$key] = $title;
  }
  if (empty($element['#type']) || !in_array($element['#type'], array(
    'radios',
    'checkboxes',
  ))) {
    foreach (element_children($element) as $child) {
      _uc_ajax_admin_list_triggers($element[$child], $list);
    }
  }
}