You are here

function views_ui_add_sort in Views (for Drupal 7) 5

Add all the info for a single sort into the form.

File

./views_ui.module, line 1556

Code

function views_ui_add_sort(&$form, $sort, &$order, $key, $i) {
  $sorts = _views_get_sorts();
  $sortname = $form['id']['#value'];

  // combined table & sortname
  $sortinfo = $sorts[$sortname];
  $form['field'] = array(
    '#type' => 'hidden',
    '#default_value' => $sort['id'],
  );
  $form['name'] = array(
    '#value' => $sortinfo['name'],
  );
  $form['sortorder'] = array(
    '#type' => 'select',
    '#title' => NULL,
    '#default_value' => $sort['sortorder'],
    '#options' => _views_sortorders(),
  );

  // option can be either 'string', 'integer', an array or a handler
  // that must return an array.
  if (isset($sortinfo['option'])) {
    $form['options'] = views_ui_setup_widget($sortinfo['option'], $sort['options']);
  }
  if (isset($sortinfo['help'])) {
    $form['help'] = array(
      '#type' => 'markup',
      '#value' => $sortinfo['help'],
    );
  }
}