_poll_choice_form
function _poll_choice_form
_poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10)
File
- modules/poll/poll.module, line 381
- Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10) { $form = array( '#tree' => TRUE, '#weight' => $weight, ); // We'll manually set the #parents property of these fields so that // their values appear in the $form_state['values']['choice'] array. $form['chid'] = array( '#type' => 'value', '#value' => $chid, '#parents' => array('choice', $key, 'chid'), ); $form['chtext'] = array( '#type' => 'textfield', '#title' => $value !== '' ? t('Choice label') : t('New choice label'), '#title_display' => 'invisible', '#default_value' => $value, '#parents' => array('choice', $key, 'chtext'), ); $form['chvotes'] = array( '#type' => 'textfield', '#title' => $value !== '' ? t('Vote count for choice @label', array('@label' => $value)) : t('Vote count for new choice'), '#title_display' => 'invisible', '#default_value' => $votes, '#size' => 5, '#maxlength' => 7, '#parents' => array('choice', $key, 'chvotes'), '#access' => user_access('administer nodes'), '#element_validate' => array('element_validate_integer'), ); $form['weight'] = array( '#type' => 'weight', '#title' => $value !== '' ? t('Weight for choice @label', array('@label' => $value)) : t('Weight for new choice'), '#title_display' => 'invisible', '#default_value' => $weight, '#delta' => $size, '#parents' => array('choice', $key, 'weight'), ); return $form; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!poll!poll.module/function/_poll_choice_form/7.x