示例#1
0
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
           <?php 
echo Html::a('Crear', '#', ['id' => 'boton_crear', 'class' => 'btn btn-success', 'data-toggle' => 'modal', 'data-target' => '#modal', 'data-url' => Url::to(['create']), 'data-pjax' => '0']);
?>
    </p>

    
      <?php 
Pjax::begin();
?>
    <?php 
echo GridView::widget(['id' => 'gridview', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id_sede', 'nombre', ['attribute' => 'id_localidad', 'value' => function ($BienesLocalidad) {
    $Localidad = BienesLocalidad::findOne($BienesLocalidad->id_localidad);
    return $Localidad->nombre;
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}{update}{delete}', 'buttons' => ['view' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', '#', ['id' => 'boton_crear', 'title' => Yii::t('app', 'Vista'), 'data-toggle' => 'modal', 'data-target' => '#modal', 'data-url' => Url::to(['view', 'id' => $model->id_sede]), 'data-pjax' => '0']);
}, 'update' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', '#', ['id' => 'boton_crear', 'title' => Yii::t('app', 'Actualizar'), 'data-toggle' => 'modal', 'data-target' => '#modal', 'data-url' => Url::to(['update', 'id' => $model->id_sede]), 'data-pjax' => '0']);
}]]]]);
Pjax::end();
?>
   
        <?php 
$this->registerJs("\$(document).on('click', '#boton_crear', (function() {\n            //funcion para que agarre el select2\n      \$.fn.modal.Constructor.prototype.enforceFocus = function() {};\n            \$.get(\n                \$(this).data('url'),\n                function (data) {\n                    \$('.modal-body').html(data);\n                    \$('#modal').modal();\n                    \n                                                              } \n            );\n        }));");
?>

    
    
 /**
  * Finds the BienesLocalidad model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BienesLocalidad the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BienesLocalidad::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\bienes\models\BienesLocalidad;
/* @var $this yii\web\View */
/* @var $model app\modules\bienes\models\BienesSede */
$this->title = 'SEDE';
?>
<div class="bienes-sede-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id_sede', 'nombre', ['attribute' => 'id_localidad', 'value' => BienesLocalidad::findOne($model->id_localidad)->nombre]]]);
?>

</div>