TDropDownList displays a dropdown list on a Web page. It inherits all properties and events from {@link TListControl}. Since v3.0.3, TDropDownList starts to support optgroup. To specify an option group for a list item, set a Group attribute with it, $listitem->Attributes->Group="Group Name"; or in template Since v3.1.1, TDropDownList starts to support prompt text. That is, a prompt item can be displayed as the first list item by specifying either {@link setPromptText PromptText} or {@link setPromptValue PromptValue}, or both. Choosing the prompt item will unselect the TDropDownList. When a prompt item is set, its index in the list is set to -1. So, the {@link getSelectedIndex SelectedIndex} property is not affected by a prompt item: the items list will still be zero-based. The {@link clearSelection clearSelection} method will select the prompt item if existing, otherway the first available item in the dropdown list will be selected.
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends TListControl, implements Prado\Web\UI\IPostBackDataHandler, implements Prado\Web\UI\IValidatable
 public function testSetDataSource()
 {
     $list = new TDropDownList();
     $data = array('a' => 1, 'b' => 2, 'c' => 3);
     $list->setDataSource($data);
     $list->dataBind();
     $items = $list->getItems();
     $this->assertTrue($items instanceof TListItemCollection);
     $expected_keys = array_keys($data);
     $i = 0;
     foreach ($items as $item) {
         $this->assertEquals($expected_keys[$i], $item->getValue());
         $this->assertEquals((string) $data[$expected_keys[$i]], $item->getText());
         $i++;
     }
 }
 protected function createTimeControl($container, $column, $record)
 {
     $value = $this->getRecordPropertyValue($column, $record);
     $hours = array();
     for ($i = 0; $i < 24; $i++) {
         $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT);
     }
     $mins = array();
     for ($i = 0; $i < 60; $i++) {
         $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT);
     }
     $hour = intval(@date('H'));
     $min = intval(@date('i'));
     $sec = intval(@date('s'));
     if (!empty($value)) {
         $match = array();
         if (preg_match('/(\\d+):(\\d+):?(\\d+)?/', $value, $match)) {
             $hour = $match[1];
             $min = $match[2];
             if (isset($match[3])) {
                 $sec = $match[3];
             }
         }
     }
     $hcontrol = new TDropDownList();
     $hcontrol->setDataSource($hours);
     $hcontrol->setID(self::DEFAULT_ID);
     $hcontrol->dataBind();
     $hcontrol->setSelectedValue(intval($hour));
     $container->Controls[] = $hcontrol;
     $container->Controls[] = ' : ';
     $mcontrol = new TDropDownList();
     $mcontrol->setDataSource($mins);
     $mcontrol->dataBind();
     $mcontrol->setID('scaffold_time_min');
     $mcontrol->setSelectedValue(intval($min));
     $container->Controls[] = $mcontrol;
     $container->Controls[] = ' : ';
     $scontrol = new TDropDownList();
     $scontrol->setDataSource($mins);
     $scontrol->dataBind();
     $scontrol->setID('scaffold_time_sec');
     $scontrol->setSelectedValue(intval($sec));
     $container->Controls[] = $scontrol;
     return array($hcontrol, $mcontrol, $scontrol);
 }
 /**
  * Updates the client-side options if the item list has changed after the OnLoad event.
  */
 public function onPreRender($param)
 {
     parent::onPreRender($param);
     $this->getAdapter()->updateListItems();
 }