Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TipoProyecto::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdTipo()
 {
     return $this->hasOne(TipoProyecto::className(), ['id' => 'id_tipo']);
 }
Ejemplo n.º 3
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>
Ejemplo n.º 4
0
 /**
  * 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.');
     }
 }
Ejemplo n.º 5
0
/* @var $this yii\web\View */
/* @var $model app\models\SubtipoProyecto */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="subtipo-proyecto-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'nombre')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'id_tipo')->widget(Select2::classname(), ['data' => ArrayHelper::map(\app\models\TipoProyecto::find()->all(), 'id', 'nombre'), 'options' => ['placeholder' => 'Seleccione una opción'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>