You are here

function i18npoll_form_alter in Internationalization 6

Implementation of hook_form_alter().

Rewrite the cancel vote form with the nid for the translation with the actual vote.

File

i18npoll/i18npoll.module, line 15
Multilingual poll - Aggregates poll results for all translations.

Code

function i18npoll_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'poll_cancel_form') {
    if (!empty($form['#nid']) && empty($form['#i18ntnid'])) {

      // Replace nid with the original node the user voted
      $node = node_load($form['#nid']);
      if (!empty($node->tnid) && ($vote = i18npoll_get_vote($node->tnid))) {
        $form['#i18ntnid'] = $node->tnid;
        $form['#nid'] = $vote->nid;
      }
    }
  }
}