You are here

function opigno_sort_groups_form in Opigno Class App 7

@file Defines all page callbacks.

1 string reference to 'opigno_sort_groups_form'
opigno_sort_groups_menu in opigno_sort_groups/opigno_sort_groups.module
Implements hook_menu().

File

opigno_sort_groups/opigno_sort_groups.pages.inc, line 8
Defines all page callbacks.

Code

function opigno_sort_groups_form($form, $form_state, $nid) {
  $form['table'] = array(
    '#tree' => TRUE,
  );
  $node = node_load($nid);
  $form['cgid'] = array(
    '#type' => 'hidden',
    '#value' => $node->nid,
  );
  foreach (opigno_sort_group_courses($node) as $coursenid) {
    $coursenode = node_load($coursenid);
    $form['table']["course_{$coursenid}"]['nid'] = array(
      '#type' => 'hidden',
      '#value' => $coursenid,
    );
    $form['table']["course_{$coursenid}"]['title'] = array(
      '#markup' => check_plain($coursenode->title),
    );
    $form['table']["course_{$coursenid}"]['weight'] = array(
      '#type' => 'weight',
      '#delta' => 50,
      '#default_value' => opigno_sort_groups_get_groups_weight($node->nid, $coursenid),
      '#attributes' => array(
        'class' => array(
          'opigno-sort-course-weight',
        ),
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t("Save order"),
  );
  return $form;
}