Decard
Decard

Reputation: 57

Yii2 how to make submit button from html a

  <?= '<li>'
           . Html::beginForm(['/site/logout'], 'post')
                  . Html::submitButton(
                            'Exit(admin)',
                            ['class' => 'btn btn-warning']
                                      )
           . Html::endForm()
    . '</li>'?>

This code is working, but I want to change submit button to html::a. When I try to do it, it's not working.

Upvotes: 0

Views: 1247

Answers (1)

Rajesh Pradhan
Rajesh Pradhan

Reputation: 210

It is not recommend to use a link as submit button, anyhow if you want, here is code

<?php echo Html::a('Exit(admin)',$url=false,['class'=>'btn btn-warning','onclick'=>'submitForm()']); ?>

in javascript

function submitForm(){
 document.getElementById('FormId').submit;
}

Upvotes: 1

Related Questions