I've an application using Yii2, basic template. In my app, I'm using Yii::$app->session-setFlash
for show a message when render a page.
When I place my application in app
, it work well. But when I move the app into module
, it didn't show a message. The module called school
This is the code I've using for showing message and render page in my app/module/school
Yii::$app->session->setFlash('error', "Error!");
return Yii::$app->response->redirect(['school/student/create']);
the page successfully return to school/student/create
page, but didn't show the message.
and this the code when I place the app in app
Yii::$app->session->setFlash('error', "Error!");
return Yii::$app->response->redirect(['create']);
the code above successfully return to page student/create
and show the message.
This is my app directory structure:
--school
--assets
--commands
--config
--controllers
--file
--mail
--models
--modules //this the module
--school
--controllers
--models
--search
--views
--Module.php
--runtime
--test
--vendor
--views
--web
.....
Anyone know why It happen? and How do I can solve this?
Anyhelp will be appreciated, thanks :)
Edited:
This is code:
app/modules/school/views/student/_form.php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\file\FileInput;
/* @var $this yii\web\View */
/* @var $model backend\models\Student */
/* @var $form yii\widgets\ActiveForm */
?>
<script type="text/javascript" src="../../web/js/jquery-1.5.2.min.js"> </script>
<div class="student-form">
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?=
$form->field($model, 'file')->widget(FileInput::classname(), [
'options' => [
'accept' => 'doc/*', 'file/*',
],
'pluginOptions' => [
'allowedFileExtensions' => ['csv', 'xls', 'xlsx'],
'showUpload' => FALSE,
'showPreview' => FALSE,
]
]);
?>
<?= Html::submitButton('<i class="glyphicon glyphicon-save-file"></i> UPLOAD', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'], ['fakturout/create']) ?>
<?php ActiveForm::end(); ?>
</div>
and
app/modules/school/view/student/create.php
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\models\Student */
$this->title = 'Student';
?>
<div class="title">
<?= Html::encode($this->title) ?>
</div>
<?=
$this->render('_form', [
'model' => $model,
])
?>