public function actionCreate()
 {
     $model = new User();
     $this->readValue($model, 'username');
     $this->readValue($model, 'email');
     $model->setPassword($this->prompt('Password:'******'required' => true, 'pattern' => '#^.{6,255}$#i', 'error' => 'More than 6 symbols']));
     $model->generateAuthKey();
     $model->role = $this->select('Role:', User::getRolesArray());
     $model->status = $this->select('Status:', User::getStatusesArray());
     $this->log($model->save());
 }
示例#2
0
文件: index.php 项目: head26/parsek
use app\common\components\grid\SetColumn;
use kartik\date\DatePicker;
use app\common\components\grid\LinkColumn;
/* @var $this yii\web\View */
/* @var $searchModel \app\modules\user\models\SearchUser */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Пользователи';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-default-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['class' => LinkColumn::className(), 'attribute' => 'username'], 'email:email', ['filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created_at', 'type' => DatePicker::TYPE_INPUT, 'separator' => '-', 'pluginOptions' => ['format' => 'yyyy-mm-dd']]), 'attribute' => 'created_at', 'format' => 'datetime'], ['class' => SetColumn::className(), 'filter' => User::getStatusesArray(), 'attribute' => 'status', 'name' => 'statusName', 'cssCLasses' => [User::STATUS_ACTIVE => 'success', User::STATUS_BLOCKED => 'default']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}&nbsp;&nbsp;{permit}&nbsp;&nbsp;{delete}', 'buttons' => ['permit' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-wrench"></span>', Url::to(['/permit/user/view', 'id' => $model->id]), ['title' => Yii::t('yii', 'Change user role')]);
}]]]]);
?>
</div>
示例#3
0
文件: _form.php 项目: head26/parsek
$form = ActiveForm::begin();
?>

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

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

    <?php 
echo $form->field($model, 'status')->dropDownList(\app\modules\user\models\User::getStatusesArray());
?>

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

    <?php 
ActiveForm::end();
?>

</div>