Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a link use POST method in Yii?

Tags:

php

yii2

In Rails we can do

= link_to 'Logout', destroy_user_session_path, method: :post

How do we achieve this in Yii? (Without having to manually create a hidden form: Make a link use POST instead of GET.)

I looked through the guide for Url for post, but couldn't find anything.

http://www.yiiframework.com/doc-2.0/guide-helper-url.html

So far I have this

%a.btn.btn-sm.btn-success{href: Url::to(['update-bid', 'change' => 'plus'])} +10%
like image 444
Chloe Avatar asked Jul 03 '15 23:07

Chloe


1 Answers

Try this:

<?= Html::a('submit', Url::to(['site/index']), ['data-method' => 'POST']) ?>
like image 86
Chinmay Waghmare Avatar answered Oct 04 '22 13:10

Chinmay Waghmare