You are here

function advpoll_merge_writein_form in Advanced Poll 7

Same name and namespace in other branches
  1. 7.3 includes/advpoll.pages.inc \advpoll_merge_writein_form()
  2. 7.2 includes/advpoll.pages.inc \advpoll_merge_writein_form()
1 string reference to 'advpoll_merge_writein_form'
advpoll_writeins_page in includes/advpoll.pages.inc

File

includes/advpoll.pages.inc, line 452

Code

function advpoll_merge_writein_form($form, &$form_state, $node) {
  $choices = $node->advpoll_choice[$node->language];
  $count = count($choices);
  $options = array();
  $all = array();
  $form['#id'] = 'advpoll-merge_writein';
  for ($i = 0; $i < $count; $i++) {
    if ($choices[$i]['write_in']) {
      $options[] = strip_tags($choices[$i]['choice']);
    }
    else {
      $all[] = strip_tags($choices[$i]['choice']);
    }
  }
  if ($options && $all) {
    $form['merge_writein'] = array(
      '#type' => 'fieldset',
      '#title' => t('Merge write-ins'),
      '#description' => t('This will delete the write-in and change any votes for it into votes for the selected choice.'),
    );
    $form['merge_writein']['choices'] = array(
      '#type' => 'select',
      '#title' => t('Merge'),
      '#options' => drupal_map_assoc($options),
    );
    $form['merge_writein']['all_choices'] = array(
      '#type' => 'select',
      '#title' => t('into'),
      '#options' => drupal_map_assoc($all),
    );
    $form['merge_writein']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Merge'),
    );
  }
  else {
    $form['merge_writein'] = array(
      '#type' => 'fieldset',
      '#title' => t('Merge write-ins'),
      '#description' => t('There are currently no write-ins to promote.'),
    );
  }
  return $form;
}