2 回答
TA贡献1812条经验 获得超5个赞
我们不能这样,它给的错误是“未定义变量角色” @php echo $roleWithId = roles[$engagement->id] @endphp
。但是,我尝试选择本身作为
{!! Form::select('roles[@php echo $engagement->id @endphp]', $userRoles, $user->privileges->where(\App\Privilege::COLUMN_ENGAGEMENT_ID, $engagement-> {\App\Engagement::COLUMN_ID})->first()[\App\Privilege::COLUMN_ROLE]) !!}
但是,它显示为
<select name="roles[<?php echo $engagement->id ?>]">
在查看源中
TA贡献1853条经验 获得超9个赞
试试这个
@foreach ($engagements as $engagement)
@php echo $roleWithId = roles[$engagement->id] @endphp
{!! Form::checkbox('engagements[]', $engagement->id, in_array($engagement->id, $user->privileges->pluck(engagement_id)->toArray()) ? true : false) !!} {{ $engagement->name }}
{!! Form::select($roleWithId , $userRoles, $user->privileges->where(engagement_id, $engagement->id)->first()[role]) !!}
@endforeach
生成要传递的字符串,并将其存储在变量中,然后在Formselect中传递该变量。
- 2 回答
- 0 关注
- 110 浏览
添加回答
举报