<bdo id='JXEfE'></bdo><ul id='JXEfE'></ul>
  1. <i id='JXEfE'><tr id='JXEfE'><dt id='JXEfE'><q id='JXEfE'><span id='JXEfE'><b id='JXEfE'><form id='JXEfE'><ins id='JXEfE'></ins><ul id='JXEfE'></ul><sub id='JXEfE'></sub></form><legend id='JXEfE'></legend><bdo id='JXEfE'><pre id='JXEfE'><center id='JXEfE'></center></pre></bdo></b><th id='JXEfE'></th></span></q></dt></tr></i><div id='JXEfE'><tfoot id='JXEfE'></tfoot><dl id='JXEfE'><fieldset id='JXEfE'></fieldset></dl></div>
    1. <tfoot id='JXEfE'></tfoot>

      <legend id='JXEfE'><style id='JXEfE'><dir id='JXEfE'><q id='JXEfE'></q></dir></style></legend>

      <small id='JXEfE'></small><noframes id='JXEfE'>

    2. Laravel 4 - 一个表单中有两个提交按钮,并且两个提交都由不同的操作处理

      Laravel 4 - two submit buttons in one form and have both submits to be handled by different actions(Laravel 4 - 一个表单中有两个提交按钮,并且两个提交都由不同的操作处理)
      • <bdo id='S33Ux'></bdo><ul id='S33Ux'></ul>
          <i id='S33Ux'><tr id='S33Ux'><dt id='S33Ux'><q id='S33Ux'><span id='S33Ux'><b id='S33Ux'><form id='S33Ux'><ins id='S33Ux'></ins><ul id='S33Ux'></ul><sub id='S33Ux'></sub></form><legend id='S33Ux'></legend><bdo id='S33Ux'><pre id='S33Ux'><center id='S33Ux'></center></pre></bdo></b><th id='S33Ux'></th></span></q></dt></tr></i><div id='S33Ux'><tfoot id='S33Ux'></tfoot><dl id='S33Ux'><fieldset id='S33Ux'></fieldset></dl></div>

                <small id='S33Ux'></small><noframes id='S33Ux'>

                <legend id='S33Ux'><style id='S33Ux'><dir id='S33Ux'><q id='S33Ux'></q></dir></style></legend>

                  <tbody id='S33Ux'></tbody>
              1. <tfoot id='S33Ux'></tfoot>
                本文介绍了Laravel 4 - 一个表单中有两个提交按钮,并且两个提交都由不同的操作处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个包含电子邮件和密码字段的登录表单.我有两个提交按钮,一个用于登录(如果用户已经注册),另一个用于注册(用于新用户).由于登录操作和注册操作不同,因此我需要某种方法将带有所有发布数据的请求重定向到其各自的操作.有没有办法在 Laravel 4 中以纯 Laravel 的方式实现这一点?

                I have a login form which has email and password fields. And I have two submit buttons, one for login ( if user is already registered ) and the other one for registration ( for new users ). As the login action and register action are different so I need some way to redirect the request with all the post data to its respective action. Is there a way to achieve this in Laravel 4 in pure Laravel way?

                推荐答案

                我会怎么做

                如果您的表单是(2 个按钮):

                If your form is (2 buttons):

                {{ Form::open(array('url' => 'test/auth')) }}
                {{ Form::email('email') }}
                {{ Form::password('password') }}
                {{ Form::password('confirm_password') }}
                <input type="submit" name="login" value="Login">
                <input type="submit" name="register" value="Register">
                {{ Form::close() }}
                

                创建一个控制器'TestController'

                Create a controller 'TestController'

                添加路线

                Route::post('test/auth', array('uses' => 'TestController@postAuth'));
                

                TestController 中,您将有一种方法来检查单击了哪个提交,以及另外两种用于登录和注册的方法

                In TestController you'd have one method that checks which submit was clicked on and two other methods for login and register

                <?php
                
                class TestController extends BaseController {
                
                    public function postAuth()
                    {
                        //check which submit was clicked on
                        if(Input::get('login')) {
                            $this->postLogin(); //if login then use this method
                        } elseif(Input::get('register')) {
                            $this->postRegister(); //if register then use this method
                        }
                
                    }    
                
                    public function postLogin()
                    {
                        echo "We're logging in";
                        //process your input here Input:get('email') etc.
                    }
                
                    public function postRegister()
                    {
                        echo "We're registering";
                        //process your input here Input:get('email') etc.
                    }
                
                }
                ?>
                

                这篇关于Laravel 4 - 一个表单中有两个提交按钮,并且两个提交都由不同的操作处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Laravel 4 - Connect to other database(Laravel 4 - 连接到其他数据库)
                Call external API function from controller, LARAVEL 4(从控制器调用外部 API 函数,LARAVEL 4)
                Empty string instead of null values Eloquent(空字符串而不是空值 Eloquent)
                quot;laravel.logquot; could not be opened: failed to open stream(“laravel.log无法打开:无法打开流)
                Displaying the Error Messages in Laravel after being Redirected from controller(从控制器重定向后在 Laravel 中显示错误消息)
                Laravel Creating Dynamic Routes to controllers from Mysql database(Laravel 从 Mysql 数据库创建到控制器的动态路由)
                  <tfoot id='BHZS4'></tfoot>
                  • <i id='BHZS4'><tr id='BHZS4'><dt id='BHZS4'><q id='BHZS4'><span id='BHZS4'><b id='BHZS4'><form id='BHZS4'><ins id='BHZS4'></ins><ul id='BHZS4'></ul><sub id='BHZS4'></sub></form><legend id='BHZS4'></legend><bdo id='BHZS4'><pre id='BHZS4'><center id='BHZS4'></center></pre></bdo></b><th id='BHZS4'></th></span></q></dt></tr></i><div id='BHZS4'><tfoot id='BHZS4'></tfoot><dl id='BHZS4'><fieldset id='BHZS4'></fieldset></dl></div>

                      <legend id='BHZS4'><style id='BHZS4'><dir id='BHZS4'><q id='BHZS4'></q></dir></style></legend>
                        <tbody id='BHZS4'></tbody>

                        <small id='BHZS4'></small><noframes id='BHZS4'>

                          <bdo id='BHZS4'></bdo><ul id='BHZS4'></ul>