vendredi 27 mai 2016

Add name and value attribute to checkbox + using Laravel

I have a problem with passing data with my checkbox to my controller.

@foreach($products $product)
<tr>
    <td>
        <input type="checkbox"  name="id[]" value="">
    </td>
    <td></td>
    <td></td>
    <td>
        @foreach($product->tags as $tag)
            ,
        @endforeach
    </td>
    <td></td>
</tr>
@endforeach

Outsite of my foreach loop, I'm defining the column names and there is where my problem starts. The first ( only important ) column is just for checkboxes

<th data-field="state" data-checkbox="true" data-sortable="false"></th>

If you see insite of my foreach loop, you will notice that there allready is a checkbox field. If I'm removing this checkbox ( the one outsite of my foreach), my whole table gets muddled up

I wan't to remove the input checkbox field in my foreach loop. I also want to add those two attributes : name="id[]" value="" to my checkbox coloumn field.

the checkbox allready have a name attribute ( name="btSelectAll" ) and I couln't overwrite it. I also haven't an idea how I can pass the product->id inside a value attribute..

At the end I just want to have the option to manually choose one or many checkboxes, or all at the same time and passing every single product->id to my controller.

Does anybody know a good solution or something?

Thanks alot for taking time and I'm really sorry for my bad english :)




Aucun commentaire:

Enregistrer un commentaire