Yii Framework Forum: How can I have two submit buttons with different actions in one form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

How can I have two submit buttons with different actions in one form Rate Topic: -----

#1 User is offline   ikramadjissa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-June 15

Posted 16 August 2015 - 10:34 AM

How can I have two submit buttons with different actions in one form . I have two actions (listenouvelleacqui, and listenouvelleacquiaffect)I am trying to include this code in my form but it's not working. it is working only with one action (listenouvelleacqui).

 <div class="col-lg-12">
    
        <?= Html::SubmitButton( 'Mettre en instance',['listenouvelleacqui', 'class' => 'btn btn-primary '] ) ?> 
   
        <?= Html::SubmitButton( 'Affecter',['listenouvelleacquiaffect','class' => 'btn btn-primary ' ] ) ?> 
  </div>


How to do that plz, any help??
0

#2 User is offline   Saurabh Dhariwal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-September 13

Posted 27 October 2015 - 08:32 AM

Syntax is improper for posting data on two different actions using two different submit buttons. You should post data by setting form actions on 'onClick' event of submit buttons as follows:

Quote

<div class="col-lg-12">
<?= Html::SubmitButton('Mettre en instance', ['class' => 'btn primary ', 'onClick' => "document.getElementById('form-id').action = 'listenouvelleacqui';"]); ?>

<?= Html::SubmitButton('Affecter', ['class' => 'btn btn-primary', 'onClick' => "document.getElementById('form-id').action = 'listenouvelleacquiaffect';"]); ?>
</div>


Hope this helps you.

Thanks
Saurabh
Thanks,
Saurabh Dhariwal
Skype ID: dhariwal.saurabh
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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