如何解决刀片中的laravel 7 route / 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方面:主页通过以下方式获取用户类型:
public function index() { $userTypes = array( 'Applicant','Business' ); return view('website::welcome',compact('userTypes')); }
-
返回视图(“网站::欢迎”
-
表示我有一个名为“网站”的软件包。
Q)我缺少什么,我的代码有什么问题?
我从registerForm遇到错误:
ParseError 语法错误,意外的'$ type'(T_VARIABLE),预期为','或')'(查看:register.blade.php)
解决方法
错误是从下面的这一行来的。
@if (isset($type == 'Business'))
您需要调用以下两个条件。 isset
和comparison
@if (isset($type) && $type== 'Business')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。