/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TeachersLevel::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, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]); return $dataProvider; }
/** * Finds the TeachersLevel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TeachersLevel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TeachersLevel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/* @var $model app\models\TeachersSearch */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="teachers-search"> <?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']); ?> <?php echo $form->field($model, 'name')->textInput(['style' => 'width:200px']); ?> <?php echo $form->field($model, 'level')->dropDownList(ArrayHelper::map(\app\models\TeachersLevel::getAllByEnd(), 'id', 'name'), ['style' => 'width:300px']); ?> <?php // echo $form->field($model, 'lesson') ?> <?php // echo $form->field($model, 'create_time') ?> <?php // echo $form->field($model, 'create_user') ?>
?> <?php echo $form->field($model, 'name')->textInput(['style' => 'width:300px']); ?> <?php echo $form->field($model, 'sex')->dropDownList(\app\models\Teachers::$sexList, ['style' => 'width:100px']); ?> <?php echo $form->field($model, 'age')->textInput(['style' => 'width:100px']); ?> <?php echo $form->field($model, 'level')->dropDownList(\app\models\TeachersLevel::getAll(), ['style' => 'width:300px']); ?> <?php echo $form->field($model, 'status')->dropDownList(\app\models\Users::$statusList, ['style' => 'width:100px']); ?> <?php echo $form->field($model, 'phone')->textInput(['style' => 'width:300px']); ?> <?php echo $form->field($model, 'email')->textInput(['style' => 'width:300px']); ?>