You are here

function advpoll_radio_selected in Advanced Poll 7.3

Same name and namespace in other branches
  1. 7 includes/advpoll_voteapi.inc \advpoll_radio_selected()
  2. 7.2 includes/advpoll_voteapi.inc \advpoll_radio_selected()

Processes votes cast via radio buttons.

Radio buttons returns a string rather than an array.

Parameters

array $choices: An array containing available choices in the poll.

array $vote: Text of choice selected from the form_state. Need to match it up with choices saved in the node.

Return value

array The unique ID of the choice selected by the user.

1 call to advpoll_radio_selected()
advpoll_form_submit in ./advpoll.module
Submit handler for voting.

File

includes/advpoll_voteapi.inc, line 410
Advanced Poll Vote API Include.

Code

function advpoll_radio_selected($choices, $vote) {
  $selected = array();
  $count = count($choices);
  for ($i = 0; $i < $count; $i++) {
    $choice = strip_tags($choices[$i]['choice_id']);
    if ($choice == strip_tags($vote)) {
      $selected[] = $choices[$i]['choice_id'];
    }
  }
  return $selected;
}