/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Menu::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'pid' => $this->pid, 'level' => $this->level, 'type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'merchant_id', $this->merchant_id])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'url', $this->url]); return $dataProvider; }
?> <?php echo $form->field($model, 'merchant_id')->hiddenInput(['value' => $merchant->id])->label(false); ?> <?php echo $form->field($model, 'pid')->dropDownList(Menu::menusMap($merchant->id)); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'type')->radioList(Menu::typeMap(), ['value' => 1]); ?> <?php echo $form->field($model, 'url')->textInput(['maxlength' => true]); ?> <div class="form-group"> <div class="col-sm-offset-2 col-sm-3"> <?php echo Html::submitButton('保 存', ['class' => 'btn btn-primary btn-block']); ?> </div> </div>
/** * Finds the Menu model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Menu the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Menu::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }