开发者

checkboxes in forms, unable to fetch the value posted in drupal

开发者 https://www.devze.com 2023-02-09 19:53 出处:网络
$langoptions = array(1=>\'German\',2=>\'English\',3=>\'Spanish\',4=>\'French\',5=>\'Portuguese\',6=>\'Chinese\',7=>\'Italian\',8=>\'Japanese\');
$langoptions = array(1=>'German',2=>'English',3=>'Spanish',4=>'French',5=>'Portuguese',6=>'Chinese',7=>'Italian',8=>'Japanese');

       $form['language'] = array(
        '#type' => 'checkboxes',
        '#title' => 'Language',
        '#multiple'=> TRUE,  
        '#options'=> $langoptions,  
      );
开发者_如何学编程

Created a list of check box like this and in callback I tried to access it as

foreach ($_POST['language'] as $key => $value) {
    echo $value;
}

and it does not display any value, can any one help me in fixing this?


If you're using standard form API, the postdata should be in $form_state['values'] at hook_submit().

Just to be sure -- have you checked any of the checkboxes prior to submitting? They will only be sent in POST if checked.

0

精彩评论

暂无评论...
验证码 换一张
取 消