/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Speciality::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, 'start_date' => $this->start_date, 'standart_id' => $this->standart_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
/** * @get speciality */ public function getSpeciality() { return $this->hasOne(Speciality::className(), ['id' => 'speciality_id']); }
<h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::button('Создать группу', ['value' => Url::to(['group/create']), 'class' => 'btn btn-success modalButton']); ?> </p> <?php Pjax::begin(['enablePushState' => false]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "\n{items}\n{pager}\n{summary}", 'options' => ['class' => 'table-responsive'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'specialityName', 'filter' => ArrayHelper::map(Speciality::find()->all(), 'name', 'name')], ['class' => 'common\\components\\ActionColumn', 'template' => '{preview} {update} {delete}', 'buttons' => ['preview' => function ($url, $model) { return Html::button('<span class="glyphicon glyphicon-eye-open"></span>', ['value' => $url, 'class' => 'btn btn-default modalButton', 'title' => Yii::t('yii', 'View'), 'aria-label' => Yii::t('yii', 'View')]); }]]]]); ?> <?php Pjax::end(); ?> <?php Modal::begin(['header' => '', 'id' => 'modal', 'size' => 'modal-lg']); echo "<div id='modalContent'></div>"; Modal::end(); ?> </div>
/** * Finds the Speciality model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Speciality the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Speciality::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/* @var $model common\models\Group */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="group-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'speciality_id')->dropDownList(ArrayHelper::map(Speciality::find()->all(), 'id', 'name')); ?> <div class="form-group"> <?php echo Html::label('Количество семестров'); ?> <?php echo Html::tag('span', null, ['id' => 'sem_count_label']); ?> <?php echo Spinner::widget(['name' => 'sem_count', 'id' => 'sem_count', 'value' => 8, 'clientOptions' => ['step' => 1]]); ?> </div> <div class="form-group">