Skip navigation
Help

theme_uc_product_kit_items_form

7 uc_product_kit.theme.inc theme_uc_product_kit_items_form($variables)

Renders the list of kit components on the product kit edit form.

Related topics

File

ubercart/uc_product_kit/uc_product_kit.theme.inc, line 13
Theme functions for the uc_product_kit module.

Code

function theme_uc_product_kit_items_form($variables) {
  $form = &$variables['form'];

  $header = array(t('Product'), t('Quantity'), t('List position'), t('Discount'));
  $rows = array();

  foreach (element_children($form) as $item) {
    $row = array(
      drupal_render($form[$item]['link']),
      drupal_render($form[$item]['qty']),
      drupal_render($form[$item]['ordering']),
      drupal_render($form[$item]['discount']),
    );
    $rows[] = array(
      'data' => $row, 
      'class' => array('draggable'),
    );
  }

  if (empty($rows)) {
    return '';
  }

  drupal_add_tabledrag('uc-product-kit-item-table', 'order', 'sibling', 'uc-product-kit-item-ordering');

  $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'uc-product-kit-item-table')));

  if (!empty($form['#description'])) {
    $output .= '<div class="description">' . $form['#description'] . "</div>\n";
  }

  return $output;
}