php - Yii radioButtonList: always takes the default value as the selected value -


i have yii radio button list follows.

forgotpassword1.php

<?php echo  $form->radiobuttonlist($model, 'send_option', $email_exist); ?> 

this action forgotpassword1.

public function actionforgotpwd2() {     $model = new user;     $email_exist = array('mobile' => 'send sms mobile');     $model -> setscenario('forgotpwd2');     $model -> send_option='mobile';      $postvars = array('conn' => yii::app()->session['mobile']);     $postres = scapputils::getinstance()->post_request('accounts', 'checkaccount', $postvars);     $out_arr = json_decode($postres, true);     //print_r($out_arr);      if ($out_arr['success'] == true && $out_arr['email'] == true) {         $email_exist['email'] = 'send e-mail';// = array('mobile' => 'send sms mobile', 'email' => '');     } else if ($out_arr['success'] == false) {         yii::app()->user->setflash('error', $out_arr['error']);         $this->redirect(array('forgotpwd1'));     }      if (!empty($_post['user'])) {         $model->attributes = $_post['user'];          echo yii::app()->session['mobile'];          //print_r($_post);         if(isset($_post['user']['send_option'])) {              //yii::app()->session['send_option'] = $model->send_option;             echo yii::app()->session['send_option'];              $postvars = array('conn' => yii::app()->session['mobile'], 'send_type' => $model->send_option);             $postres = scapputils::getinstance()->post_request('accounts', 'changepassword', $postvars);             $out_arr = json_decode($postres, true);             // print_r($out_arr);              if ($out_arr['success'] == true) {                   $this->redirect(array('forgotpwd3'));             } else {                  yii::app()->user->setflash('error', $out_arr['error']);             }          }     }      $this->render('forgotpwd2', array(         'model' => $model, 'email_exist' => $email_exist     ));  } 

here call function named "changepassword()" backend application. 1 of parameters passed backend send_type: mobile or email. problem takes mobile send_type. i've used

$model -> send_option='mobile'; 

to set default value mobile.

why takes mobile send type.

any suggestions appreciated.

thank in advance

try :

<?=$form->radiobuttonlist($model,'send_option',array(1=>'mobile',2=>'email'))?> 

in acion :

  • to set default value :

    $model -> send_option=1; 
  • to checked value (check whether it's 1 or 2) :

    $_post['send_option']  

hope helps.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -