Yii Framework Forum: Html::submitButton should open in new tab - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Html::submitButton should open in new tab

#1 User is offline   mrxc0d3r 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-October 17

Posted 12 October 2017 - 11:42 AM

Hi everybody,
How to add option target=>_blank in my code.

<?= Html::submitButton($model->isNewRecord ?    ' <i class="fa fa-save"></i>   Save & Print' : ' <i class="fa fa-save"></i>   Save & Print', ['target'=>'_blank'] , ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>


Anybody know this ? Thanks
0

#2 User is offline   umneeq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 160
  • Joined: 10-October 11
  • Location:Russia

Posted 13 October 2017 - 08:16 AM

https://github.com/y...seHtml.php#L516
0

#3 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,491
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 13 October 2017 - 01:57 PM

you can't put target=_blank on submit button

<?= Html::submitButton($model->isNewRecord ?    ' <i class="fa fa-save"></i>   Save & Print' : ' <i class="fa fa-save"></i>   Save & Print', ['target'=>'_blank'] , ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

// your code outputs a button tag something like

<button>...</button>



change it to a anchor tag and your target=_blank should work as expected

<?= Html::a('Link', 'path_to_your_link', ['target'=>'_blank', 'class' => 'btn btn-primary']) ?>

0

#4 User is offline   jkofsky 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 688
  • Joined: 17-May 10
  • Location:Pensacola, Florida

Posted 18 October 2017 - 04:04 PM

View Postmrxc0d3r, on 12 October 2017 - 11:42 AM, said:

Hi everybody,
How to add option target=>_blank in my code.

<?= Html::submitButton(' <i class="fa fa-save"></i>   Save & Print', 
['target'=>'_blank'] , ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>


Anybody know this ? Thanks

<?= Html::submitButton(' <i class="fa fa-save"></i>   Save & Print', 
['target'=>'_blank', 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>


The 'target' and 'class' array options need to be in the same array[]. I also simplified your label code ('Save & Print' where the same whether isNewRecord or not)
Do, or do not. There is no 'try.' Jedi Master Yoda
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users