You are here

function theme_uc_object_attributes_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_attribute/uc_attribute.module \theme_uc_object_attributes_form()
  2. 6.2 uc_attribute/uc_attribute.admin.inc \theme_uc_object_attributes_form()

Displays the formatted attribute form.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

See also

uc_object_attributes_form()

File

uc_attribute/uc_attribute.admin.inc, line 690
Attribute administration menu items.

Code

function theme_uc_object_attributes_form($variables) {
  $form = $variables['form'];
  $output = '';
  if ($form['view']['#value'] == 'overview') {
    $header = array(
      t('Remove'),
      t('Name'),
      t('Label'),
      t('Default'),
      t('Required'),
      t('List position'),
      t('Display'),
    );
    $rows = array();
    foreach (element_children($form['attributes']) as $aid) {
      $rows[] = array(
        'data' => array(
          drupal_render($form['attributes'][$aid]['remove']),
          drupal_render($form['attributes'][$aid]['name']),
          drupal_render($form['attributes'][$aid]['label']),
          drupal_render($form['attributes'][$aid]['option']),
          drupal_render($form['attributes'][$aid]['required']),
          drupal_render($form['attributes'][$aid]['ordering']),
          drupal_render($form['attributes'][$aid]['display']),
        ),
        'class' => array(
          'draggable',
        ),
      );
    }
    drupal_add_tabledrag('uc-attribute-table', 'order', 'sibling', 'uc-attribute-table-ordering');
    if ($form['type']['#value'] == 'class') {
      $path = url('admin/store/products/classes/' . $form['id']['#value'] . '/attributes/add');
    }
    elseif ($form['type']['#value'] == 'product') {
      $path = url('node/' . $form['id']['#value'] . '/edit/attributes/add');
    }
    $output = theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => 'uc-attribute-table',
      ),
      'empty' => t('You must first <a href="!url">add attributes to this !type</a>.', array(
        '!url' => $path,
        '!type' => $form['type']['#value'],
      )),
    ));
  }
  else {
    $output = '<div class="uc-attributes-add-link">';
    $output .= t('You may add more attributes <a href="!url">here</a>.', array(
      '!url' => url('admin/store/products/attributes/add'),
    ));
    $output .= '</div>';
  }
  $output .= drupal_render_children($form);
  return $output;
}