lundi 30 novembre 2020

Send multiple checkbox via get request in array

I am filtering my products by colors in my Laravel 8 application. And I want to send a get request. Here are my colors

<label class="w-full flex items-center space-x-2">
    <span>
        <input type="checkbox"
            onChange="this.form.submit()"
            name="colors[]"
            value=""
            @if(in_array($color->id, $selectedColors)) checked @endif />
    </span>
    <span class="block -mt-1 select-none"> </span>
</label>

enter image description here

Now the result I am getting from this

enter image description here

I am getting an array but the color word is repeating in URL with special characters. I want to get it like this colors=[1,2,3] OR this colors = 1,2,3

How can I achieve this?

Thanks




Aucun commentaire:

Enregistrer un commentaire