I need to create a checkbox in Laravel 5.1 with a name like so:
<input type="checkbox" name="groups[1]">
<input type="checkbox" name="groups[2]">
I am using the following code, but it doesn't work. Does anyone know the correct way to code this?
{!! Form::checkbox('groups[{{ $user->id }}]', 'administrator', in_array('Administrator', $user->roles()->lists('name')->toArray())) !!}
The output I get is:
<input checked="checked" name="groups[<?php echo e($user->email); ?>]" value="administrator" type="checkbox">
You cannot use blade inside php. Just concatinate the id
as normal.
Try this:
Form::checkbox('groups['.$user->id.']', 'administrator', in_array('Administrator', $user->roles()->lists('name')->toArray())) !!}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.