0

我正在使用 Drupal 6 并创建一个涉及表单提交的模块。我选择使用#type“radio”,因为它允许我动态创建一个表(这是显示目的所必需的)。

我正在输出我在图像中选择的每个收音机的返回值。但是,每当我提交表单时,都会返回 #default_value 而不是 #return_value。

这是我的代码以及页面的屏幕截图。任何帮助是极大的赞赏!

======这里的问题图片=======

function peereval_survey(&$formstate, $numStudents)
{
drupal_add_css(drupal_get_path('module', 'peereval') .'/peereval.css');

for ($rowNum = 1; $rowNum <= $numStudents; $rowNum++)
{
    for ($colNum = 1; $colNum <= 5; $colNum++)
    {
        if ($rowNum == 1)
        {
            $form['v' . $colNum]['u' . $rowNum . ',v' . $colNum] = array
            (
                '#prefix' => "<tr><td>",
                '#suffix' => "</td>",
                '#type' => 'radio',
                '#title' => t($rowNum . ', ' . $colNum),
                '#name' => 'u' . $rowNum,   
                '#default_value' => 0,
                '#return_value' => $colNum,
            );
        }           
        else if ($rowNum == 5)
        {
            $form['v' . $colNum]['u' . $rowNum . ',v' . $colNum] = array
            (
                '#prefix' => "<td>",
                '#suffix' => "</td></tr>",
                '#type' => 'radio',
                '#title' => t($rowNum . ', ' . $colNum),
                '#name' => 'u' . $rowNum,
                '#default_value' => 0,
                '#return_value' => $colNum,
            );
        }
        else
        {
            $form['v' . $colNum]['u' . $rowNum . ',v' . $colNum] = array
            (
                '#prefix' => "<td>",
                '#suffix' => "</td>",
                '#type' => 'radio',
                '#title' => t($rowNum . ', ' . $colNum),
                '#name' => 'u' . $rowNum,
                '#default_value' => 0,
                '#return_value' => $colNum,
            );
        }
    }
}

$form['numStudents'] = array
(
    '#type' => 'hidden',
    '#value' => $numStudents
);

$form['submit'] = array
(
    '#prefix' => '<div id="submit">',
    '#suffix' => '</div>',
    '#type' => 'submit',
    '#value' => t('Save'),  
);

return $form;
}

 

function peereval_survey_submit($form, &$form_state)
{
$form_state['redirect'] = 'peereval/1/5/1';

drupal_set_message("hi" . $form_state['values']['u1,v1'] . $form_state['values']['u2,v2'] . $form_state['values']['u3,v3'] . $form_state['values']['u4,v4'] . $form_state['values']['u5,v5']);

return $form;
}
4

1 回答 1

0

以下变量包含我的数据:

$form_state['clicked_button']['#post']['u1'], 
$form_state['clicked_button']['#post']['u2'],
$form_state['clicked_button']['#post']['u3'], 
$form_state['clicked_button']['#post']['u4'], 
$form_state['clicked_button']['#post']['u5']. 

非常感谢 Adam Balsam 帮我找到这个!

于 2013-03-23T00:06:36.593 回答