theme from uc_attribute.admin.inc with draggable rows, modified

function phptemplate_uc_object_options_form($form) {
  $header = array(t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('List position'), t('Image'), t('Preview'), t('Remove'));
  $table_id_num = $tables = 0;

  foreach (element_children($form['attributes']) as $key) {

    $rows = array();

    if (element_children($form['attributes'][$key]['default'])) {

      foreach (element_children($form['attributes'][$key]['default']) as $oid) {
        $row = array(
          drupal_render($form['attributes'][$key]['options'][$oid]['select']),
          drupal_render($form['attributes'][$key]['default'][$oid]),
          drupal_render($form['attributes'][$key]['options'][$oid]['cost']),
          drupal_render($form['attributes'][$key]['options'][$oid]['price']),
          drupal_render($form['attributes'][$key]['options'][$oid]['weight']),
          drupal_render($form['attributes'][$key]['options'][$oid]['ordering']),
          drupal_render($form['attributes'][$key]['options'][$oid][uc_option_image_id(arg(1), $key, $oid)]), 
          drupal_render($form['attributes'][$key]['options'][$oid]['option_image_preview']),
          drupal_render($form['attributes'][$key]['options'][$oid]['remove']),
        );

        $rows[] = array(
          'data' => $row,
          'class' => 'draggable',
        );
      }
      $table_id = 'uc-attribute-option-table-'. $table_id_num++;
      drupal_add_tabledrag($table_id, 'order', 'sibling', 'uc-attribute-option-table-weight');
    }
    else {
      $row = array();
      $row[] = array('data' => drupal_render($form['attributes'][$key]['default']), 'colspan' => 9);
      $rows[] = $row;
    }

    if (!count($rows)) {
      $rows[] = array(array('data' => t('This !type does not have any attributes.', array('!type' => $form['type']['#value'] == 'product' ? t('product') : t('product class'))), 'colspan' => 9));
    }

    
    $output .= theme('table', $header, $rows, array('class' => 'product_attributes', 'id' => $table_id), '<h2>'. drupal_render($form['attributes'][$key]['name']) .'</h2>');

    $tables++;
  }

  if (!$tables) {

    $output .= '<br /><br />';
    if ($form['type']['#value'] == 'product') {
      drupal_set_message(t('This product does not have any attributes.'), 'warning');
    }
    else {
      drupal_set_message(t('This product class does not have any attributes.'), 'warning');
    }
  }
  
  $output .= drupal_render($form);

  return $output;
}

Comments

acouch’s picture

Status: Active » Closed (won't fix)

This is code for uc_attributes which is part of Ubercart. Feel free to bounce it over there if you want to pursue this.