/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AboutUsType::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(['aboutustype_id' => $this->aboutustype_id]); $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'orderoftype', $this->orderoftype]); return $dataProvider; }
/** * Finds the AboutUsType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AboutUsType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AboutUsType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
//use yii\widgets\ActiveForm; use yii\helpers\Arrayhelper; use backend\models\AboutUsType; /* @var $this yii\web\View */ /* @var $model backend\models\AboutUs */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="about-us-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'aboutustype_id')->dropDownList(ArrayHelper::map(AboutUsType::find()->all(), 'aboutustype_id', 'type'), ['prompt' => 'Select Type']); ?> <?php echo $form->field($model, 'subsection')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'suborder')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> <?php