You are here

function flag_lists_handler_field_ops::views_form in Flag Lists 7

Same name and namespace in other branches
  1. 7.3 includes/flag_lists_handler_field_ops.inc \flag_lists_handler_field_ops::views_form()

File

includes/flag_lists_handler_field_ops.inc, line 62

Class

flag_lists_handler_field_ops

Code

function views_form(&$form, &$form_state) {

  // The view is empty, abort.
  if (empty($this->view->result)) {
    return;
  }
  $form[$this->options['id']] = array(
    '#tree' => TRUE,
  );

  // At this point, the query has already been run, so we can access the results
  // in order to get the base key value (for example, nid for nodes).
  foreach ($this->view->result as $row_index => $row) {
    $entity_id = $this
      ->get_value($row);
    if ($this->options['flo']['force_single']) {
      $form[$this->options['id']][$row_index] = array(
        '#type' => 'radio',
        '#parents' => array(
          $this->options['id'],
        ),
        '#return_value' => $entity_id,
      );
    }
    else {
      $form[$this->options['id']][$row_index] = array(
        '#type' => 'checkbox',
        '#return_value' => $entity_id . (isset($row->flag_lists_flags_fid) ? '-' . $row->flag_lists_flags_fid : ''),
        '#default_value' => FALSE,
        '#attributes' => array(
          'class' => array(
            'flo-select',
          ),
        ),
      );
    }
  }
}