Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii2:需要点击提交按钮两次,名称和id不是;提交;_Php_Html_Forms_Yii2 - Fatal编程技术网

Php Yii2:需要点击提交按钮两次,名称和id不是;提交;

Php Yii2:需要点击提交按钮两次,名称和id不是;提交;,php,html,forms,yii2,Php,Html,Forms,Yii2,问题:我在一个页面中有三个表单,它们都有相同的错误:我需要单击提交按钮两次才能提交表单 我发现这是一个常见的错误,通常通过将按钮命名为“提交”触发,但事实并非如此 这是我的密码: (第一种形式:更改密码) (第二种形式:更改电子邮件) (第三种形式:更改用户名) 如您所见,提交按钮具有唯一的ID和名称,它们被正确解析为所需的HTML代码 例如,“更改密码”的提交按钮如下所示: <button type="submit" id="submit-change-password" c

问题:我在一个页面中有三个表单,它们都有相同的错误:我需要单击提交按钮两次才能提交表单

我发现这是一个常见的错误,通常通过将按钮命名为“提交”触发,但事实并非如此

这是我的密码:

(第一种形式:更改密码)


(第二种形式:更改电子邮件)


(第三种形式:更改用户名)


如您所见,提交按钮具有唯一的ID和名称,它们被正确解析为所需的HTML代码

例如,“更改密码”的提交按钮如下所示:

<button type="submit" id="submit-change-password" class="btn btn-primary" name="submit-change-password" style="width: 100%">Change Password</button>
更改密码

对于这种情况有什么解决方案或变通办法吗?我只找到了重命名“提交”按钮的解决方案。

第一次查看时,我没有发现任何可疑之处。您是否尝试查看控制台以查看是否有任何错误?开发工具控制台不会抛出任何错误,Yii2开发工具也不会。从这里我无法分辨任何错误。在您提供的代码之外,可能有某些内容阻止提交表单。例如,可能是来自JavaScript的内容。
<div id="change-email-form">
    <?php $changeEmailForm = ActiveForm::begin([
        'id'          => 'change-email-form',
        "options"     => ["class" => "animated-label"],
        "fieldConfig" => ["template" => "{input}\n{label}\n{hint}\n{error}"],
    ]); ?>

    <div class="row">
        <div class="col-md-6">
            <?= $changeEmailForm->field($changeEmail, 'password')->passwordInput() ?>
        </div>
        <div class="col-md-6">
            <?= $changeEmailForm->field($changeEmail, 'email')->textInput() ?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6 col-md-offset-6">
            <?= Html::submitButton(
                'Change Email',
                [
                    'class' => 'btn btn-primary',
                    "style" => "width: 100%",
                    'name'  => 'submit-change-email',
                    'id'    => 'submit-change-email',
                ]
            ) ?>
        </div>
    </div>

    <?php ActiveForm::end(); ?>
</div>
<div id="change-username-form">
    <?php $changeUsernameForm = ActiveForm::begin([
        'id'          => 'change-username-form',
        "options"     => ["class" => "animated-label"],
        "fieldConfig" => ["template" => "{input}\n{label}\n{hint}\n{error}"],
    ]); ?>

    <div class="row">
        <div class="col-md-6">
            <?= $changeUsernameForm->field($changeUsername, 'password')->passwordInput() ?>
        </div>
        <div class="col-md-6">
            <?= $changeUsernameForm->field($changeUsername, 'username')->textInput() ?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6 col-md-offset-6">
            <?= Html::submitButton(
                'Change Username',
                [
                    'class' => 'btn btn-primary',
                    "style" => "width: 100%",
                    'name'  => 'submit-change-username',
                    'id'    => 'submit-change-username',
                ]
            ) ?>
        </div>
    </div>
    <?php ActiveForm::end(); ?>
</div>
<button type="submit" id="submit-change-password" class="btn btn-primary" name="submit-change-password" style="width: 100%">Change Password</button>