/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AclRole::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, 'created_by' => $this->created_by, 'modified_by' => $this->modified_by, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
public function getRole() { return $this->hasOne(AclRole::className(), ['id' => 'role_id']); }
?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'password')->passwordInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'status')->dropDownList(['Active' => 'Active', 'Inactive' => 'Inactive'], ['prompt' => 'Select Status']); ?> <?php echo $form->field($model, 'role_id')->dropDownList(ArrayHelper::map(AclRole::find()->where(['status' => 'Active'])->all(), 'id', 'name'), ['prompt' => 'Select Role']); ?> <div class='col-sm-12 col-md-12'> <div class="form-group pull-right"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> <?php ActiveForm::end(); ?> </div>
/** * Finds the AclRole model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AclRole the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AclRole::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }