Search code examples
phpyiiradiobuttonlist

Yii : hide items of radioButtonList


In Yii I have form which contains radioButtonList as follows:

<?php echo  $form->radioButtonList($model, 'send_option', array('mobile'=>'Send SMS to Mobile','email'=>'Send an E-mail')); ?>

I an very newbie to Yii. I wanna hide the second item (i.e. Send an E-mail) of the list.

Any suggetions are appreciated.

Thank you in advance


Solution

  • You can remove this by Yii clientScript. Something like below

    Yii::app()->clientScript->registerScript('search', "
        $('#ModelClassName_send_option_1').hide(); 
        //If your model class name is Message (eg) then it should be $('#Message_send_option_1').hide();
        $('label[for=\"ModelClassName_send_option_1\"]').hide();
    ");
    

    Or you can remove it from array. simply

    <?php echo  $form->radioButtonList($model, 'send_option', array('mobile'=>'Send SMS to Mobile',)); ?>