- Edited
I have a search form with input fields and 2 submit buttons Search and Export. When the user clicks on Search button then index action should execute and when user clicks on Export button then export action should execute. Now even if user clicks on Export button export action is not executed.
Below is the search form
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Asccenter;
use app\models\Ascuser;
?>
<?php $form = ActiveForm::begin([
'method' => 'get',
'id'=>'form1'
]); ?>
<?= $form->field($model, 'ASCId')->dropDownList()?> <?php //Input field 1?>
<?= $form->field($model, 'UserId')?> <?php // Input field 2?>
<?= $form->field($model, 'Year')?> <?php // Input field 3?>
<div class="form-group">
<?php // Search button. When user clicks on Search button then index action should execute ?>
<?= Html::submitButton('Search' ,['class' => 'btn btn-primary','id'=>'searchbutton','name'=>'search1','value'=>'search2']) ?>
<?php //Reset button to clear the form inputs?>
<?= Html::a('Reset',['index'], ['class' => 'btn btn-default']) ?>
<?php // Export button. When user clicks on Export button, then export action should execute?>
<?= Html::submitButton('Export', ['class' => 'btn btn-default','id'=>'exportbutton','name'>'search1','value'=>'export1']) ?>
</div>
<?php ActiveForm::end(); ?>
Below is the Controller
<?php
namespace app\controllers;
use Yii;
use app\models\Ascteacherreport;
use app\models\AscteacherreportSearch;
use yii\helpers\ArrayHelper;
class AscteacherreportController extends Controller
{
public function actionIndex()
{
// When user clicks on Search button then this action should execute
}
public function actionExport()
{
// When user clicks on Export button of the form then form parameters will be loaded and this action should execute.
}
}