/** * Lists all UserGroup models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => UserGroup::find(), 'pagination' => ['class' => 'yii\\data\\Pagination', 'defaultPageSize' => 16], 'sort' => ['class' => 'yii\\data\\Sort', 'defaultOrder' => ['sort' => SORT_ASC]]]); // $total = $dataProvider->getTotalCount(); // 整个数据库表的总数(使用这个,可以触发前端知道还有next页面) // $models = $dataProvider->getModels(); return $this->render('index', ['dataProvider' => $dataProvider]); }
?> <?php echo $form->field($model, 'realname', ['inputOptions' => ['placeholder' => $model->getAttributeLabel('realname')]])->textInput(); ?> <?php echo $form->field($model, 'email', ['inputOptions' => ['placeholder' => $model->getAttributeLabel('email')]])->input('email'); ?> <?php echo $form->field($model, 'password', ['inputOptions' => ['placeholder' => $model->getAttributeLabel('password')]])->passwordInput(); ?> <?php echo $form->field($model, 'user_group_id')->label(Yii::t('user', 'User Group'))->dropDownList(ArrayHelper::map(UserGroup::find()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'role_name')->label(Yii::t('user', 'Role'))->dropDownList(ArrayHelper::map(Yii::$app->getAuthManager()->getRoles(), 'name', 'description')); ?> <?php echo $form->field($model, 'status')->checkbox(['value' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>