Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks for the tip @Andrew. Here's what I ended up coming up with:</p> <pre><code>function stannes_content_multiple_values($element) { global $user; $field_name = $element['#field_name']; $field = content_fields($field_name); $output = ''; if ($field['multiple'] &gt;= 1) { $table_id = $element['#field_name'] .'_values'; $order_class = $element['#field_name'] .'-delta-order'; $required = !empty($element['#required']) ? '&lt;span class="form-required" title="'. t('This field is required.') .'"&gt;*&lt;/span&gt;' : ''; $header = array( array( 'data' =&gt; t('!title: !required', array('!title' =&gt; $element['#title'], '!required' =&gt; $required)), 'colspan' =&gt; 2) ); if ($user-&gt;uid == 1) { $header[] = t('Order'); } $rows = array(); // Sort items according to '_weight' (needed when the form comes back after // preview or failed validation) $items = array(); foreach (element_children($element) as $key) { if ($key !== $element['#field_name'] .'_add_more') { $items[] = &amp;$element[$key]; } } usort($items, '_content_sort_items_value_helper'); // Add the items as table rows. foreach ($items as $key =&gt; $item) { $item['_weight']['#attributes']['class'] = $order_class; $delta_element = drupal_render($item['_weight']); if ($user-&gt;uid == 1) { $cells = array( array('data' =&gt; '', 'class' =&gt; 'content-multiple-drag'), drupal_render($item), array('data' =&gt; $delta_element, 'class' =&gt; 'delta-order'), ); } else { $cells = array( drupal_render($item) ); } $rows[] = array( 'data' =&gt; $cells, 'class' =&gt; 'draggable', ); } $output .= theme('table', $header, $rows, array('id' =&gt; $table_id, 'class' =&gt; 'content-multiple-table')); $output .= $element['#description'] ? '&lt;div class="description"&gt;'. $element['#description'] .'&lt;/div&gt;' : ''; $output .= drupal_render($element[$element['#field_name'] .'_add_more']); if ($user-&gt;uid == 1) { drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class); } } else { foreach (element_children($element) as $key) { $output .= drupal_render($element[$key]); } } return $output; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload