/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Userroles::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Finds the Userroles model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Userroles the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Userroles::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
?>

    <?php 
echo $form->field($model, 'username')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'first_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'last_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'user_role_id')->dropDownList(ArrayHelper::map(Userroles::find()->all(), 'id', 'name'), ['prompt' => 'Select Role']);
?>

    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'password')->passwordInput(['maxlength' => true]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>