Hi, I am using Yii 2 basic application template.
I have a controller called Ascteacherreport and search model for the same.
I have the CRUD for the above controller. User can create, delete and update the model data.
I have the search form enabled on index page. I need to get the parameters of the search form and pass it to the controller Ascteacherreport action.
_search
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Asccenter;
use app\models\Ascuser;
/* @var $this yii\web\View */
/* @var $model app\models\AscteacherreportSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="ascteacherreport-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="row">
<div class="col-sm-3">
<?= $form->field($model, 'ASCId')->dropDownList()?>
</div>
<div class="col-sm-3">
<?= $form->field($model, 'UserId')->dropDownList()?>
</div>
<div class="col-sm-3">
<?= $form->field($model, 'Year') ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::a('Reset',['index'], ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
In the controller, AscteacherreportController()
<?php
namespace app\controllers;
use Yii;
use app\vendor\phpoffice\phpexcel\Classes\PHPExcel;
use app\models\Ascteacherreport;
use app\models\AscteacherreportSearch;
use yii\web\Controller;
class AscteacherreportController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
}
public function actionData() // This action should receive/get the search form parameters
{
// load search form model
$model = new AscteacherreportSearch();
// work with the search form parameters
echo $model->ASCId." - ".$model->UserId." - ".$model->Year;
}
}