Laravel Blade速记三元运算符无法正常工作

时间:2016-01-03 17:57:27

标签: laravel-5.1 ternary-operator laravel-blade

我正在使用laravel collective来生成我的表单,在其中一个下拉列表中,我有以下三元运算符:

 {!! Form::select('department_id', ['' => 'Please select'] + $departments, isset($user->departmentStaff->department_id) ? $user->departmentStaff->department_id : null , ['class' => 'form-control']) !!}

然而,laravel速记三元运算符不起作用,它会抛出错误:

{!! Form::select('department_id', ['' => 'Please select'] + $departments, $user->departmentStaff->department_id or null , ['class' => 'form-control']) !!}

这来自官方文档:https://laravel.com/docs/5.2/blade#control-structures

0 个答案:

没有答案