You are here

function advpoll_promote_writein_form in Advanced Poll 7.3

Same name and namespace in other branches
  1. 7 includes/advpoll.pages.inc \advpoll_promote_writein_form()
  2. 7.2 includes/advpoll.pages.inc \advpoll_promote_writein_form()

Form builder for promoting write-in options.

Used to promote write-in options to normal status on the write-in node management tab page.

1 string reference to 'advpoll_promote_writein_form'
advpoll_writeins_page in includes/advpoll.pages.inc
Displays Write-in node management tab page.

File

includes/advpoll.pages.inc, line 478
Advanced Poll Pages Include.

Code

function advpoll_promote_writein_form($form, &$form_state, $node) {
  $data = advpoll_get_data($node);
  $count = count($data->choices);
  $options = array();
  for ($i = 0; $i < $count; $i++) {
    if ($data->choices[$i]['write_in']) {
      $options[] = strip_tags($data->choices[$i]['choice']);
    }
  }
  $form['#id'] = 'advpoll-promote_writein';
  if ($options) {
    $form['promote_writein'] = array(
      '#type' => 'fieldset',
      '#title' => t('Promote write-ins'),
      '#description' => t('Write-ins can be converted to regular choices. This is useful if users cannot see past write-ins but you want to promote specific write-ins so that they can be seen by users who vote in the future.'),
    );
    $form['promote_writein']['choices'] = array(
      '#type' => 'checkboxes',
      '#title' => '',
      '#options' => drupal_map_assoc($options),
    );
    $form['promote_writein']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Promote'),
    );
  }
  else {
    $form['promote_writein'] = array(
      '#type' => 'fieldset',
      '#title' => t('Promote write-ins'),
      '#description' => t('There are currently no write-ins available to promote.'),
    );
  }
  return $form;
}