You are here

function theme_mvf_unit_suggesters_settings in Measured Value Field 7

Default theme implementation of hook 'mvf_unit_suggesters_settings'.

We sort form elements into a table, adding draggable weights for better UI experience.

Parameters

array $vars: Arguments for theming

Return value

string Themed HTML string of the supplied arguments

1 theme call to theme_mvf_unit_suggesters_settings()
mvf_element_info in ./mvf.module
Implements hook_element_info().

File

./mvf.module, line 1579
Define a field type of measured value.

Code

function theme_mvf_unit_suggesters_settings($vars) {
  $table_id = 'mvf-unit-suggesters-settings-table';
  $group = 'mvf-order';
  $table = array();
  $table['header'] = array(
    t('Enable'),
    t('Weight'),
    t('Settings'),
  );
  $table['caption'] = $vars['element']['#title'];
  $table['attributes'] = array(
    'id' => $table_id,
  );
  $table['rows'] = array();
  foreach (element_children($vars['element']) as $child) {
    $vars['element'][$child]['weight']['#attributes']['class'][] = $group;
    $table['rows'][] = array(
      'data' => array(
        drupal_render($vars['element'][$child]['enable']),
        drupal_render($vars['element'][$child]['weight']),
        // Rendering whatever is left, whatever left probably will be custom
        // form elements, provided by that Unit Suggester in "getSettingsForm"
        // method.
        drupal_render($vars['element'][$child]),
      ),
      'class' => array(
        'draggable',
      ),
    );
  }
  drupal_add_tabledrag($table_id, 'order', 'sibling', $group);
  return theme('table', $table) . drupal_render_children($vars['element']);
}