/**
  * Finds the TipoProyecto model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TipoProyecto the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TipoProyecto::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\SubtipoProyectoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Subtipo Proyectos');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="subtipo-proyecto-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Subtipo Proyecto'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'nombre', ['attribute' => 'id_tipo', 'value' => function ($data) {
    return \app\models\TipoProyecto::findOne(['id' => $data->id_tipo])->nombre;
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>