summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/tickets/protected/pages/DActiveDropDownList2.php
blob: 4d354dcc9d3e96944b6c0e6c76b77a384a6b6e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
Prado::using('System.Web.UI.ActiveControls.*');
class DActiveDropDownList2 extends TActiveDropDownList
{
    public function setOpcoes($val)
    {
        $this->setViewState('Opcoes', $val);
    }

    public function loadOptions()
    {
        $opcao =  $this->getViewState('Opcoes');

        switch ($opcao) {
            case "turnos":
                $this->DataTextField="descricao";
                $this->DataValueField="id_turno";
                $opts = array(
                    array('id_turno' => 'M', 'descricao' => 'Manhã'),
                    array('id_turno' => 'T', 'descricao' => 'Tarde'),
                    array('id_turno' => 'N', 'descricao' => 'Noite')
                );
                break;

            default:
                throw new TConfigurationException('Falta argumento OPCOES no DActiveDropDownList');
                break;
        }
        $this->setDataSource($opts);
        $this->dataBind();
    }
}