Link to home
Start Free TrialLog in
Avatar of DennisHacker
DennisHackerFlag for United States of America

asked on

Yii 1.1 Limiting choices on a dropdown

With the following code in place:

 <?php echo $form->dropDownListRow($model, 'specialty_id', DoctorSpecialty::listOptions()); ?>

How would I limit the possible choices to just two of four?  I can't delete the other two from the table because they are used in the database in other places.
Avatar of Chad Haney
Chad Haney
Flag of United States of America image

I'm not experienced with Yii, but from what I am reading on listOptions, it outputs a string, which is the html li markup. I would try to make a custom function on the DoctorSpecialty model which removes the unwanted values temporarily then collect the listOptions, put the unwanted values back in and return the collected options.


Another option I am seeing is to use Chtml.
<?php echo $form->dropDownListRow($model, 'specialty_id', CHtml::listData(
        DoctorSpecialty::model()->->find($condition,$params), 
        'id_column', 'value_column'
     ));?>

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.