views:

48

answers:

1

Hi guys! Sorry for this question, but is it possible to make radio buttons instead of select list from this piece of code?

function _nodereview_form_review(&$form, $axis, $node) {
  static $options;
  if (!isset($options)) {
    $options = array(
 20 => -2,
 40 => -1,
 60 => 0,
 80 => 1,
 100 => 2,
    );
 }

$form['reviews'][$axis->aid] = array(
  '#type' => 'fieldset',
  '#title' => $axis->tag,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
);

$form['reviews'][$axis->aid]['score'] = array(
  '#type' => 'select',
  '#title' => t('Score'),
  '#options' => $options,
  '#default_value' => $node->reviews[$axis->aid]['score'] ? $node->reviews[$axis->aid]['score'] : 50,
  '#description' => $axis->description,
  '#required' => TRUE,
);


if (NODEREVIEW_FIVESTAR_ENABLE) {
  $form['reviews'][$axis->aid]['score']['#type'] = 'fivestar';
  $form['reviews'][$axis->aid]['score']['#stars'] = variable_get('nodereview_fivestar_stars', 5);
}

$form['reviews'][$axis->aid]['review'] = array(
  '#type' => 'textarea',
  '#title' => t('Review'),
  '#default_value' => $node->reviews[$axis->aid]['review'],
  '#required' => TRUE,
);
}

I know that '#type' => 'select' should be '#type' => 'radio', but something else also should be changed. I don't know what exactly.

Any suggestions are gratefully accepted.

A: 

Well, for starters, the #options will need to be converted to the value for each radio button. You'll also probably need to add labels for each button as well.

idrumgood
I'm trying to use foreach ($options as $key => $option) { $form['reviews'][$axis->aid]['score'] = array( '#type' => 'radio', '#title' => $option, '#default_value' => $node->reviews[$axis->aid]['score'] ? $node->reviews[$axis->aid]['score'] : NULL, ); }but it's not working...