lundi 6 avril 2015

how to pass the value of checkboxes as an array from view to controller in laravel 4

i wanna know how to pass the value of several checkboxes as an array from my view to controller. here is my code:


my view:



@extends('layouts.master')

@section('content')

<?php
$count = 1;
?>

{{ Form::open(array('method' => 'POST', 'action' => array('createQuizController@addQuestion'), 'id' => 'add_question')) }}

<div class="col-lg-10 col-lg-offset-1">
<div class="table-responsive" id="question_table">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>ردیف</th>
<th>عنوان سوال</th>
<th></th>
</tr>
</thead>

<tbody>
@foreach ($result as $quiz)
<tr>
<td align="center" width="100px">
<?php echo $count++; ?>
</td>
<td align="center" width="200px">{{ $quiz->title }}</td>
<td align="center" width="200px"><input type="checkbox" name="select_question[]" id="counter[]" value="{{ $quiz->lesson_id }}"></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
{{ Form::submit('افزودن', ['class' => 'btn btn-primary']) }}

{{ Form::close() }}

<input type="text" id="count-checked" name="count-checked">

@stop


i want to post the value of checkbox ; $quiz->lesson_id as an array to my controller method addQuestion.


Aucun commentaire:

Enregistrer un commentaire