laravel 7 route/url Blade 中的参数
laravel 7 route/url param in Blade
我试图通过 GET 请求将参数 type=Business 传递给
注册表格.
在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'));
}
return 查看('website::welcome'
表示我有自己的名为“网站”的包。
问)我遗漏了什么,我的代码有什么问题?
我收到来自 registerForm 的错误:
解析错误
语法错误,意外的“$type”(T_VARIABLE),需要“,”或“)”(视图:register.blade.php)
错误来自下面这一行。
@if (isset($type == 'Business'))
您需要调用以下两个条件。对于 isset
和 comparison
@if (isset($type) && $type== 'Business')
我试图通过 GET 请求将参数 type=Business 传递给 注册表格.
在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')); }
return 查看('website::welcome'
表示我有自己的名为“网站”的包。
问)我遗漏了什么,我的代码有什么问题?
我收到来自 registerForm 的错误:
解析错误 语法错误,意外的“$type”(T_VARIABLE),需要“,”或“)”(视图:register.blade.php)
错误来自下面这一行。
@if (isset($type == 'Business'))
您需要调用以下两个条件。对于 isset
和 comparison
@if (isset($type) && $type== 'Business')