Reputation: 2966
Is it possible to open in a new window when i click a submit button ? I have TWO SUBMIT buttons in my active form.
I know if i give 'target'=>'_blank'
i will get the desired result in normal cases but it didn't work in active form.
<?php $form = ActiveForm::begin(); ?>
<div class="form-group">
<div class="col-md-6">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Submit') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<div class="col-md-6">
<?= Html::submitButton('Pdf', ['class' => 'btn btn-primary','name'=>'Pdf'],['target'=>'_blank']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
I tried as above. then i decided to give target => _blank
to active form as shown below
<?php $form = ActiveForm::begin(
['options'=>['target'=>'_blank']]); ?>
It works but not in the desired way. Now if i click on any one of the buttons i will be redirected to new page. I only want to get redirected to new page when i click on button 'Pdf'. Any Ideas?
I don't want any javascript to be used.
Upvotes: 0
Views: 3416
Reputation: 114
form = ActiveForm::begin(
['options'=>['target'=>'_blank']]);
it needs to work
Upvotes: 1
Reputation: 9358
You can use anchor for new window.
<?= Html::a('Pdf', 'url', ['class' => 'btn btn-primary','name'=>'Pdf', 'target'=>'_blank']) ?>
Upvotes: 1