duanhunlou7051 2016-08-30 13:49
浏览 10

Laravel提交按钮重新路由到主页

So I used the default Registration Form Laravel.

Made copy of the Registration Form to make a slightly different one.

Basically there is two sign up forms

  1. Starter - original

  2. Bronze - Copy

--My Routing List--

Auth::routes();
Route::get('/register', function(){
  return View::make('auth.register');
});

Route::get('/bronze', function(){
  return View::make('auth.bronze');
});

Route::get('/login', function(){
  return View::make('auth.login');
});

Now every time I submit the bronze sign up form, it redirects me to my home page.

I'm thinking maybe its my Action call in my view. which is identical to the Starter Form

<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">

if I'm correct what I just did is bad practice, but I'm a new-bie at this framework.

  • 写回答

2条回答 默认 最新

  • douse8732 2016-08-30 14:23
    关注

    You need to explicitly add a POST route, as the Auth::routes() method only handles calls to /register:

    Route::post('/bronze', 'Auth\RegisterController@register');

    And make sure you submit the Bronze form to the same route:

    <form class="form-horizontal" role="form" method="POST" action="/bronze">

    Alternatively, and possibly a better solution, would be to just use the same registration form and have an input for their account type selection:

    <form class="form-horizontal" role="form" method="POST" action="/register">
    
        <input type="radio" name="type" id="type-starter" value="starter">
        <label for="type-starter">Starter</label>
    
        <input type="radio" name="type" id="type-bronze" value="bronze">
        <label for="type-bronze">Bronze</label>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?