Blade 中的 laravel 7 路由/url 参数

麦克罗

我试图通过 GET 请求将参数 type=Business 传递给 RegisterForm。

  • 在 Welcome.blade 中

  • 我有两个指向 RegisterForm 的链接。

         @if (Route::has('register'))
         <a href="register?type=Business">Register Business</a>
         <a href="register?type=Applicant">Register Applicant</a>
         @endif
    
  • 在 RegisterForm 中,我有这样的隐藏字段:

       @if (isset($type))
       <input id="userType" type="hidden" class="form-control" name="userType" value="{{ $type }}">
        @endif
    
  • 甚至尝试过这种方式:

        @if (isset($type == 'Business'))
         <input id="userType" type="hidden" class="form-control" name="userType" value="{{ $type }}">
        @endif  
    
  • 在 Laravel 方面:主页通过以下方式获取 userTypes:

      public function index()
      {
    
     $userTypes = array(
     'Applicant',
     'Business'       
     );
     return view('website::welcome', compact('userTypes'));
    }
    
  • 返回视图('网站::欢迎'

  • 意味着我有自己的名为“网站”的包。

问)我错过了什么,我的代码有什么问题?

我从 registerForm 收到错误:

ParseError 语法错误,意外的 '$type' (T_VARIABLE),期待 ',' 或 ')' (查看:register.blade.php)

迪利普·希拉帕拉

错误来自下面这一行。

 @if (isset($type == 'Business'))

您需要调用以下两个条件。对于issetcomparison

@if (isset($type) && $type== 'Business')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章