I have been able to dynamically populate checkboxes in my view. But I am having problem in reading the checked checkboxes in my controller. I want id, name and value of the checkboxes. For example, if I have two checkboxes, then I want each checkbox's id, name and value indicating whether checked or not. Right now all I am getting is an array that just gives values 1.
I have the view:
<div class="control-group">
{{ Form::label('permission-lbl', 'Permissions') }}
<div class="controls">
@foreach($permissions as $p)
{{ Form::checkbox('permissions[]',$p->id,false,array('class'=>'permission')) }} {{Form::label('permissions[]',$p->name)}}
@endforeach
</div>
</div>
And the controller is:
public function store() {
$validation = new CreateGroupValidator;
if ($validation->passes()) {
try {
// Create the group
$permissions = Input::get('permissions');
if(is_array($permissions))
{
//i need each checkbox's id, name and value here
}
$group = Sentry::createGroup(array(
'name' => Input::get('name')
));
Notification::success('New group was saved.');
return Redirect::route('admin.groups.index');
}
catch (\Cartalyst\Sentry\Groups\GroupExistsException $e)
{
Notification::error('A group with same name already exists.');
}
}
return Redirect::back()->withInput()->withErrors($validation->errors);
}
Any suggestions please?