'as beforeAction' => function () {
//Тут ваши действия для анонимной функции
}
'as beforeAction' => [
'class' => app\modules\users\behaviors\LastVisitBehavior::class
],
Url::current(['ref' => null]);
/**
* Страница сохранения реферера (пригласившего)
*
* @param int $id
*
* @return Response|string
*/
public function actionReferral(int $id)
{
if (Yii::$app->user->isGuest) {
ReferralHelper::setReferrerId($id);
}
return $this->redirect('site/registration');
}
/**
* Страница регистрации
*
* @return Response|string
* @throws \yii\base\InvalidArgumentException
* @throws \yii\db\Exception
*/
public function actionRegistration()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$userForm = new UserForm();
if ($userForm->load(Yii::$app->request->post())) {
$referrerId = ReferralHelper::getReferrerId();
$referrer = $referrerId !== null ? $this->getUser((int)$referrerId) : null;
$userForm->setReferrer($referrer);
if ($userForm->save() && $userForm->login()) {
$message = 'Спасибо за регистрацию.';
if ($referrer !== null) {
$message .= ' Вас пригласил ' . $referrer;
}
Yii::$app->session->setFlash('success', $message);
ReferralHelper::removeReferrer();
return $this->goHome();
}
$this->addErrorForForm($userForm);
}
$userForm->password = '';
return $this->render('registration', [
'model' => $userForm,
]);
}
class ReferralHelper
{
const KEY_REFERRER_ID = 'referrer_id';
public static function setReferrerId(int $referrerId)
{
\Yii::$app->getSession()->set(self::KEY_REFERRER_ID, $referrerId);
}
public static function getReferrerId()
{
return \Yii::$app->getSession()->get(self::KEY_REFERRER_ID, null);
}
public static function removeReferrer()
{
return \Yii::$app->getSession()->remove(self::KEY_REFERRER_ID);
}
}
return [
'viewPath' => '@app/modules/users/views/frontend',
];
return [
'components' => [
'view' => [
'theme' => [
'basePath' => '@app/themes/basic',
'baseUrl' => '@web/themes/basic',
'pathMap' => [
'@app/views' => '@app/themes/basic',
],
],
],
],
];
return [
'modules' => [
'users' => [
'class' => app\modules\users\Module::class,
'controllerNamespace' => 'app\modules\users\controllers\frontend',
'viewPath' => '@app/modules/users/views/frontend',
'layout' => '@app/views/layouts/column2-right.php',
],
]
'modules' => [
'api' => [
'class' => app\modules\api\Module::class,
'modules' => [
'v1' => [
'class' => app\modules\api\modules\v1\Module::class,
'controllerMap' => [
'organizations' => \app\modules\organizations\api\controllers\DefaultController::class,
'users' => \app\modules\users\api\Controllers\DefaultController::class,
'cities' => \app\modules\api\modules\v1\controllers\events\CitiesController::class,
],
]
],
],
],
class DefaultController extends ActiveController
{
public $modelClass = Organization::class;
public $serializer = [
'class' => 'yii\rest\Serializer',
'collectionEnvelope' => 'items',
];
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
return $behaviors;
}
public function actions()
{
$actions = parent::actions();
unset($actions['delete'], $actions['create'], $actions['view']);
return $actions;
}
}
[
'class' => 'yii\rest\UrlRule',
'controller' => ['api/v1/organizations'],
'extraPatterns' => [
'GET, POST find' => 'find',
],
],
'components' => [
'response' => [
// ...
'formatters' => [
\yii\web\Response::FORMAT_JSON => [
'class' => yii\web\JsonResponseFormatter::class,
'prettyPrint' => YII_DEBUG, // используем "pretty" в режиме отладки
'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
],
],
],
'as contentNegotiator' => [
'class' => \yii\filters\ContentNegotiator::class,
'formatParam' => '_format',
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
'application/octet-stream' => \yii\web\Response::FORMAT_JSON,
'text/html' => \yii\web\Response::FORMAT_JSON,
'application/xml' => \yii\web\Response::FORMAT_XML,
],
],
],
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\PathController', /////ВОТ ЗДЕСЬ ДОЛЖНО БЫТЬ!
'access' => ['@'],
'root' => [
'baseUrl'=>'/web',
// 'basePath'=>'@webroot',
'path' => 'upload/global',
'name' => 'Global'
],
]
],
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort'=> [
'attributes' => [
'age',
'name' => [
'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
'default' => SORT_DESC,
'label' => 'Name',
],
],
]);
$actionColumnSetting = [
'buttons' => [
'view' => function($name, $model, $key){
return Html::a('<i class="fas fa-eye" aria-hidden="true"></i>', ['update']);
},
'update' => function($name, $model, $key){
return Html::a('<i class="fas fa-pencil-alt" aria-hidden="true"></i>', ['update']);
},
'delete' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['delete']);
}
],
];
\Yii::$container->set(ActionColumn::class, $actionColumnSetting);
$actionColumnSetting = [
'buttons' => [
'view' => function($name, $model, $key){
return Html::a('<i class="fas fa-eye" aria-hidden="true"></i>', ['edit']);
},
'update' => function($name, $model, $key){
return Html::a('<i class="fas fa-pencil-alt" aria-hidden="true"></i>', ['update']);
},
'delete' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['delete']);
},
'archive' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['archive']);
}
],
];
\Yii::$container->set(ActionColumn::class, $actionColumnSetting);
public function isAnswerExists($answers){}
$question = 1;
foreach ($questions as $key => $question) {
$questionPoint = new QuestionPoint($question);
$questionPoint->isAnswerExists($question, $answer)
}
<?php $form = ActiveForm::begin([
'layout'=>'horizontal',
'options' => ['class' => 'signup-form form-register1'],
'fieldConfig' => [
'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
'horizontalCssClasses' => [
'label' => 'col-sm-4',
'offset' => 'col-sm-offset-4',
'wrapper' => 'col-sm-8',
'error' => '',
'hint' => '',
],
],
]); ?>
<?= Html::activeLabel($model, 'password') ?>
<?= Html::activePasswordInput($model, 'password') ?>
<?= Html::error($model, 'password') ?>
or
<?= Html::activeLabel($model, 'username', ['label' => 'name']) ?>
<?= Html::activeTextInput($model, 'username') ?>
<div class="hint-block">Please enter your name</div>
<?= Html::error($model, 'username') ?>
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'showPageSummary'=>true,
'panel'=>[
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-book"> Library',
'before'=>'{dynagrid}' . Html::a('Custom Button', '#', ['class'=>'btn btn-default'])
],
]
/*<!--Устраняем баг Select2-->*/
$(document).ready(function () {
$.fn.modal.Constructor.prototype.enforceFocus = function () {
};
});
/*<!--/Устраняем баг Select2-->*/
$(".select2me-filter").select2("destroy");
... Here do option updates you need
$(".select2me-filter").select2();
'modules'=>[
'dynagrid'=> [
'class'=>'\kartik\dynagrid\Module',
// other module settings
],
'gridview'=> [
'class'=>'\kartik\grid\Module',
// other module settings
],
];
<?= \kartik\dynagrid\DynaGrid::widget([
'columns' => $columns,
'theme'=>'panel-warning',
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'showPageSummary'=>true,
'panel'=>[
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-book"> Library',
'before'=>'{dynagrid}' . Html::a('Custom Button', '#', ['class'=>'btn btn-secondary'])
],
]
]); ?>