Ejemplo n.º 1
0
 public static function findAllForDropDownList()
 {
     $models = Paises::find()->orderBy('nombre_pais')->all();
     $listData = [];
     foreach ($models as $model) {
         if (intval($model->id)) {
             $listData[$model->id] = $model->nombre_pais;
         }
     }
     return $listData;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Paises::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]);
     $query->andFilterWhere(['like', 'nombre_pais', $this->nombre_pais]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
use app\models\Paises;
/* @var $this yii\web\View */
/* @var $searchModel app\models\AutoresBusqueda */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Autores';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="autores-index">

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

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'idpais', 'filter' => ArrayHelper::map(Paises::find()->asArray()->all(), 'id', 'nombre'), 'label' => 'País', 'content' => function ($model, $key, $index, $column) {
    return Html::a($model->idpais0->nombre, ['autores/por-pais', 'idPais' => $model->idpais0->id], ['data-pjax' => 0]);
}], 'nombre', 'apellidos', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>