function _poll_choice_form

Constructs one individual form choice as part of poll node form.

See also

poll_form()

1 call to _poll_choice_form()
poll_form in drupal/core/modules/poll/poll.module
Implements hook_form().

File

drupal/core/modules/poll/poll.module, line 381
Collects 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' => 'number',
    '#title' => $value !== '' ? t('Vote count for choice @label', array(
      '@label' => $value,
    )) : t('Vote count for new choice'),
    '#title_display' => 'invisible',
    '#default_value' => $votes,
    '#min' => 0,
    '#parents' => array(
      'choice',
      $key,
      'chvotes',
    ),
    '#access' => user_access('administer nodes'),
  );
  $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;
}