You are here

function theme_commerce_line_item_manager in Commerce Core 7

Themes the line item manager widget form element.

1 theme call to theme_commerce_line_item_manager()
commerce_line_item_field_widget_form in modules/line_item/commerce_line_item.module
Implements hook_field_widget_form().

File

modules/line_item/commerce_line_item.module, line 1171
Defines the core Commerce line item entity and API functions interact with line items on orders.

Code

function theme_commerce_line_item_manager($variables) {
  drupal_add_css(drupal_get_path('module', 'commerce_line_item') . '/theme/commerce_line_item.admin.css');
  $form = $variables['form'];
  $rows = array();

  // Add each line item to the table.
  foreach (element_children($form['line_items']) as $line_item_id) {
    $row = array();

    // Loop over all child elements in the line item's form array.
    foreach (element_children($form['line_items'][$line_item_id]) as $item) {

      // Do not attempt to render value elements into the row.
      if (!empty($form['line_items'][$line_item_id][$item]['#type']) && $form['line_items'][$line_item_id][$item]['#type'] == 'value') {
        continue;
      }
      $row[] = drupal_render($form['line_items'][$line_item_id][$item]);
    }
    $rows[] = $row;
  }

  // Setup the table's variables array and build the output.
  $table_variables = array(
    'caption' => check_plain($form['#title']),
    'header' => $form['#header'],
    'rows' => $rows,
    'empty' => $form['#empty'],
  );
  $output = theme('table', $table_variables) . drupal_render($form['actions']);
  return '<div id="line-item-manager" class="clearfix">' . $output . '</div>';
}