Пример #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTest()
 {
     return $this->hasOne(Test::className(), ['id' => 'test_id']);
 }
Пример #2
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();
Пример #3
0
 /**
  * Finds the Test model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Test the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Test::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }