mercredi 18 mai 2016

pass multiple id's from checkboxes to my controller with Laravel

I have a products table in my database. I'm getting the name of the products from my DB and print theire names in a bootstrap table on my blade. Currently there is a edit button on every row line. If I'm pressing the button I'm passing the ID of this product to my controller edit function. Now I want to add checkboxes for every product in this table and if I set for example two ticks ( so two different products ) I want to pass both ID's at the same time to my controller.

Looks like this:

            {!! Form::open(['action' => 'ProductController@tags']) !!}
            @foreach($products as $product)
                <tr>
                    <td>
                        {!! Form::checkbox('check', $product->id) !!}
                    </td>

                    <td>
                        
                    </td>

                    <td>
                    @foreach($product->tags as $tag)
                        ,
                    @endforeach
                    </td>

                    <td>
                        
                    </td>

                    <td>
                    <a href="">
                    <button class="btn btn-default" style="float: right;">Edit</button>
                    </a>
                    </td> 
                </tr>
            @endforeach
            {!! Form::close() !!}

As you see, I've set the product id as a seccond parameter for every checkbox, but this haven't worked well of course. Can someone tell me a way how I can give every checkbox the ID of the product and pass multiple ID's to my controller at the same time?

Thanks for taking the time :)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1sxYPe9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire