本文整理汇总了PHP中common\models\User::statuses方法的典型用法代码示例。如果您正苦于以下问题:PHP User::statuses方法的具体用法?PHP User::statuses怎么用?PHP User::statuses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::statuses方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules
/**
* @inheritdoc
*/
public function rules()
{
return [['username', 'trim'], ['username', 'required'], ['username', 'match', 'pattern' => '#^[\\w_-]+$#i'], ['username', 'unique', 'targetClass' => User::className(), 'filter' => function ($query) {
if (!$this->getModel()->isNewRecord) {
$query->andWhere(['not', ['id' => $this->getModel()->id]]);
}
}], ['username', 'string', 'min' => 2, 'max' => 32], ['email', 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'unique', 'targetClass' => User::className(), 'filter' => function ($query) {
if (!$this->getModel()->isNewRecord) {
$query->andWhere(['not', ['id' => $this->getModel()->id]]);
}
}], ['email', 'string', 'max' => 255], ['password', 'required', 'on' => 'create'], ['password', 'string', 'min' => 6, 'max' => 32], ['status', 'integer'], ['status', 'in', 'range' => array_keys(User::statuses())], ['roles', 'each', 'rule' => ['in', 'range' => ArrayHelper::getColumn(Yii::$app->authManager->getRoles(), 'name')]]];
}
示例2: json_encode
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('user', 'List users');
?>
<div class="user-index">
<br>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'email', 'format' => 'raw', 'value' => function ($data) {
return Html::a($data->email, Url::to(['update', 'id' => $data->id]));
}], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => User::statuses(), 'attribute' => 'status', 'url' => ['ajaxUpdate'], 'type' => 'select', 'display' => "colors", 'editableOptions' => function ($model) {
return ['source' => User::statuses(), 'value' => $model->status];
}], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => User::roles(), 'attribute' => 'role', 'url' => ['ajaxUpdate'], 'value' => function ($data) {
return User::getRole($data->role);
}, 'type' => 'select', 'display' => "function(value,sourceData,response){console.log(sourceData);}", 'editableOptions' => ['source' => Yii::$app->user->identity->getEditableRoles(), 'sourceCache' => false]], ['attribute' => 'created_at', 'filter' => false, 'format' => 'datetime'], ['attribute' => 'updated_at', 'filter' => false, 'format' => 'datetime'], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
<script>
function colors(value, sourceData) {
var selected = $.grep(sourceData, function (o) {
return value == o.value;
}),
colors = <?php
echo json_encode(User::$status_colors);
?>
;
示例3:
<div class="user-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'username');
?>
<?php
echo $form->field($model, 'email');
?>
<?php
echo $form->field($model, 'password')->passwordInput();
?>
<?php
echo $form->field($model, 'status')->dropDownList(User::statuses());
?>
<?php
echo $form->field($model, 'roles')->checkboxList($roles);
?>
<div class="form-group">
<?php
echo Html::submitButton(Yii::t('backend', 'Save'), ['class' => 'btn btn-primary', 'name' => 'signup-button']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
示例4:
?>
<?php
echo $form->field($user, 'username')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($user, 'password')->passwordInput(['maxlength' => true]);
?>
<?php
echo $form->field($user, 'email')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($user, 'status')->label(Yii::t('backend', 'Status'))->radioList(User::statuses());
?>
<?php
echo $form->field($user, 'roles')->checkboxList($roles);
?>
<?php
echo $form->field($profile, 'firstname')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($profile, 'lastname')->textInput(['maxlength' => true]);
?>
<?php
示例5:
<?php
use common\grid\EnumColumn;
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Users');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => 'User']), ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'username', 'email:email', ['class' => EnumColumn::className(), 'attribute' => 'status', 'enum' => User::statuses(), 'filter' => User::statuses()], 'created_at:datetime', 'logged_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
示例6: function
use yii\bootstrap\Html;
use yii\grid\GridView;
use common\models\User;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Users');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">
<p>
<?php
echo Html::a(Yii::t('backend', 'Create user'), ['create'], ['class' => 'btn btn-success']);
?>
<?php
echo Html::a(Yii::t('backend', 'Roles'), ['/rbac/access/role'], ['class' => 'btn btn-success']);
?>
<?php
echo Html::a(Yii::t('backend', 'Permissions'), ['/rbac/access/permission'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'username', 'email:email', ['attribute' => 'status', 'value' => function ($model) {
return User::statuses($model->status);
}, 'filter' => User::statuses()], 'ip', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>
</div>