/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TipoCombustivel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'nome' => $this->nome]);
     return $dataProvider;
 }
 public function afterFind()
 {
     $this->id_cor = Cor::findOne($this->id_cor)->nome;
     $this->id_tipo_combustivel = TipoCombustivel::findOne($this->id_tipo_combustivel)->nome;
     $this->id_modelo = Modelo::findOne($this->id_modelo)->nome;
     switch ($this->status) {
         case '1':
             $this->status = 'Leiloado';
             break;
         case '2':
             $this->status = 'Disponível';
             break;
         case '3':
             $this->status = 'Alocado';
             break;
     }
 }
 /**
  * Finds the TipoCombustivel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TipoCombustivel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TipoCombustivel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
?>

    <?php 
echo $form->field($model, 'potencia')->textInput();
?>

    <?php 
echo $form->field($model, 'id_modelo')->dropDownList(ArrayHelper::map(Modelo::find()->all(), 'id', 'nome'), ['prompt' => 'Selecione uma opção']);
?>

    <?php 
echo $form->field($model, 'id_cor')->dropDownList(ArrayHelper::map(Cor::find()->all(), 'id', 'nome'), ['prompt' => 'Selecione uma opção']);
?>

    <?php 
echo $form->field($model, 'id_tipo_combustivel')->dropDownList(ArrayHelper::map(TipoCombustivel::find()->all(), 'id', 'nome'), ['prompt' => 'Selecione uma opção']);
?>

    <?php 
echo $form->field($model, 'ano_fabricacao')->dropDownList(array_combine(range(date('Y') + 1, 1900, -1), range(date('Y') + 1, 1900, -1)), ['prompt' => 'Selecione uma opção']);
?>

    <?php 
echo $form->field($model, 'ano_modelo')->dropDownList(array_combine(range(date('Y') + 1, 1900, -1), range(date('Y') + 1, 1900, -1)), ['prompt' => 'Selecione uma opção']);
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Novo' : 'Atualizar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>