Month Loop In Dropdown?

please any one tell me month loop in dropdown from jan to dec…or range loop ??? :rolleyes:




for($i=1; $i<13; ++$i)

  echo Yii::app()->locale->getMonthName($i);



Oh, you want that for a dropdown. Use CLocale.getMonthNames(). That’ll return a ready-to-use array for you.

its working fine but its not showing values in drop down how to show all values in drop down Thanx in advance

Well, how are you feeding the date to the dropdown? Can you show me some code?


<?php


for($i=1; $i<13; ++$i)


   Yii::app()->locale->getMonthName($i);

   echo $form->dropdownlist($model,'getMonthName($i)'); 

 

Year Loop In Dropdown

Only “Day Loop In Dropdown” left and you’ll have the full set ;)

Oooookay … I think what you really want to do is this:




echo $form->dropDownList($model,'month',CHtml::encodeArray(Yii::app()->locale->getMonthNames()));



Thanks aloooooot dear Really really thanks problem solved