You are here

function theme_opigno_sort_groups_form in Opigno Class App 7

Theme callback: render the order form.

File

opigno_sort_groups/opigno_sort_groups.module, line 80
Contains all hook_implementations and module specific functions.

Code

function theme_opigno_sort_groups_form($vars) {
  $form = $vars['form'];
  drupal_add_tabledrag('opigno-sort-course', 'order', 'sibling', 'opigno-sort-course-weight');
  $header = array(
    t("Courses"),
    t("Weight"),
  );
  $rows = array();
  foreach ($form['table'] as $key => $item) {
    if (preg_match('/course_[0-9]+/', $key)) {
      $data = array();
      $data[] = drupal_render($item['title']) . drupal_render($item['nid']);
      $data[] = drupal_render($item['weight']);
      $rows[] = array(
        'data' => $data,
        'class' => array(
          'draggable',
        ),
      );
    }
  }
  $form['table'] = array(
    '#markup' => theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => 'opigno-sort-course',
      ),
    )),
    '#weight' => 1,
  );
  return drupal_render_children($form);
}