Bloodhound
Bloodhound

Reputation: 2966

Click a button twice to POST

this my view file for a signin page

<?php $form = ActiveForm::begin(); ?>

    <?= $form->field( $model, 'email' )->textInput( [ 'maxlength' => 200 ], [ 'id' => 'email' ] ) ?>

    <?= $form->field( $model, 'password' )->passwordInput( [ 'maxlength' => 200 ] ) ?>

    <div class="form-group">
        <div class="col-lg-offset-1 col-lg-14">
            <?= Html::submitButton( 'Login',
                [ 'class' => 'btn btn-danger btn-block btn-lg', 'name' => 'login-button' ] ) ?>
        </div>
    </div>

    <input type='sub' name='submit' value='Reset Password' class="btn btn-link btn-default" '>

    <?php ActiveForm::end(); ?>

it works perfectly but you have to click on the login button twice. there is no other problem in signing in. i don't have a clue why i have to click the login button twice.

Upvotes: 0

Views: 1085

Answers (2)

David Newcomb
David Newcomb

Reputation: 10943

name='submit' is your problem here. Change it to name='not_submit' and all will be well.

The post here explains why name='submit' causes problems for ActiveForm.

Yii2 form submit button must be clicked two times for action. How to prevent this?

Upvotes: 2

Patryk Radziszewski
Patryk Radziszewski

Reputation: 511

Firstly You've got syntax in your input type='sub' at the end You've got ' instead of /. You should render it by Html::input, then you'll avoid syntax.

Secondly change this input name. name='submit' brookes ActiveForm. Not sure why...

Upvotes: 2

Related Questions