Example #1
0
<?php

use kartik\grid\GridView;
use kartik\builder\TabularForm;
use yii\data\ArrayDataProvider;
use yii\helpers\Html;
use yii\widgets\Pjax;
Pjax::begin();
$dataProvider = new ArrayDataProvider(['allModels' => $row]);
echo TabularForm::widget(['dataProvider' => $dataProvider, 'formName' => 'ReportTest', 'checkboxColumn' => false, 'actionColumn' => false, 'attributeDefaults' => ['type' => TabularForm::INPUT_TEXT], 'attributes' => ['test_id' => ['label' => 'Test', 'type' => TabularForm::INPUT_WIDGET, 'widgetClass' => \kartik\widgets\Select2::className(), 'options' => ['data' => \yii\helpers\ArrayHelper::map(\app\models\plrs\Test::find()->orderBy('id')->asArray()->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Choose Test')]], 'columnOptions' => ['width' => '200px']], 'result' => ['type' => TabularForm::INPUT_TEXT], 'del' => ['type' => TabularForm::INPUT_STATIC, 'label' => '', 'value' => function ($model, $key) {
    return Html::a('<i class="glyphicon glyphicon-trash"></i>', '#', ['title' => Yii::t('app', 'Delete'), 'onClick' => 'delRowReportTest(' . $key . '); return false;', 'id' => 'report-test-del-btn']);
}]], 'gridSettings' => ['panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> ' . Yii::t('app', 'Report Test') . '  </h3>', 'type' => GridView::TYPE_INFO, 'before' => false, 'footer' => false, 'after' => Html::button('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('app', 'Add Row'), ['type' => 'button', 'class' => 'btn btn-success kv-batch-create', 'onClick' => 'addRowReportTest()'])]]]);
Pjax::end();
Example #2
0
 /**
  * Lists all Test models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Test::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }