/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Aeroporto the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Aeroporto::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
echo $form->labelEx($model, 'id_aeroporto_1'); ?> <?php echo CHtml::activeDropDownList($model, 'id_aeroporto_1', Aeroporto::getListaAeroportos(), array('empty' => '')); ?> <?php echo $form->error($model, 'id_aeroporto_1'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'id_aeroporto_2'); ?> <?php echo CHtml::activeDropDownList($model, 'id_aeroporto_2', Aeroporto::getListaAeroportos(), array('empty' => '')); ?> <?php echo $form->error($model, 'id_aeroporto_2'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Cadastrar' : 'Salvar'); ?> </div> <?php $this->endWidget(); ?>
public static function getListaAeroportos() { return CHtml::listData(Aeroporto::model()->findAll(array('order' => 'nome')), 'id', 'nome'); }
<div id="relatorio" class="main-content"> <h1> Gerar Relatório </h1> <?php echo CHtml::form('relatorio', 'post', array('target' => '_blank')); echo CHtml::label('Aeroporto: ', 'aeroporto'); echo CHtml::dropDownList('aeroporto', '', Aeroporto::getListaAeroportos(), array('empty' => 'Todos')); echo "<br />"; echo CHtml::label('Quantidade: ', 'qtdVoos'); echo CHtml::dropDownList('qtdVoos', '', array('10' => '10', '25' => '25', '50' => '50', '100' => '100'), array('empty' => 'Sem Limite')); echo "<br />"; echo CHtml::submitButton('Emitir Relatório'); echo CHtml::endForm(); ?> </div>