t('Summaries demo'), 'page callback' => 'summaries_demo', 'access arguments' => array('access content'), ); return $items; } function summaries_demo() { $forms = array( 'uc_cart_cart_settings_form' => array(), ); foreach ($forms as $form_id => $args) { $form_state = array('storage' => NULL, 'submitted' => FALSE); $form = drupal_retrieve_form($form_id, $form_state); drupal_prepare_form($form_id, $form, $form_state); } //return '
'. print_r($form, TRUE) .''; return theme('item_list', _summary_build($form)); } /** * Recursively builds the data array for a form summary. * * @param $form * The form array we need to summarize. * @return * A structured array as expected by theme_item_list(). */ function _summary_build($form) { $items = array(); // Loop through each element in $form. foreach(element_children($form) as $key) { // Check for an element-defined summary. if (isset($form[$key]['#summary'])) { $summary = $form[$key]['#summary']; // Check what kind of summary has been defined. if (is_array($summary) && count($summary) > 0) { $callback = array_shift($summary); if ($callback === FALSE) { // If the first value in the array is (bool) FALSE, then it signifies // we should do something special. if (count($summary) == 0) { // If the summary array only contained one FALSE value, then we // silently add the summaries of any child elements to the current // summary array in place of this summary. $items += _summary_build($form[$key]); } else { // If the summary array contained more values, use the next value // as the full summary text. $items[] = array_shift($summary); } } else { // Otherwise, we expect it to be a valid callback and pass the // remaining values to the function as arguments. $items[] = call_user_func_array($callback, $summary); } } else { // Otherwise use the format #title: summary. $items[] = $form[$key]['#title'] .': '. $summary; } } else { // Check the type and use the default summary style. switch ($form[$key]['#type']) { case 'fieldset': $items[] = array( 'data' => $form[$key]['#title'], 'children' => _summary_build($form[$key]), ); break; case 'textfield': $items[] = $form[$key]['#title'] .': '. check_plain($form[$key]['#default_value']); break; case 'select': case 'radios': $items[] = $form[$key]['#title'] .': '. $form[$key]['#options'][$form[$key]['#default_value']]; break; } } } return $items; }