سؤال

I want to know how to preselect an option using the radiobuttonlistrow in yiibooster, I have read the yii documentation and in the case of radiobuttonlist it doest have an option to preselect the value but with yiibooster I can't find anyway to do this.

Any help will be highly appreciate

Gabriel

هل كانت مفيدة؟

المحلول

For this you have to know the option values before you render the View. For example in your view

<?php echo $form->radioButtonList($model,'attribute', array('0'=>'option1 ', '1'=>'option 2 ', '2'=>'option3 ')); ?>

Then before rendering this view in you action write

$model->attribute='1';

Then option1 will be selected when the raioButtonList is rendered.Similarly you can select other options as per your needs

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top