Home > OS >  dropdwon send always last value in filter
dropdwon send always last value in filter

Time:01-17

i'm trying to do a filter using Dropdown but it's always sending the last value to the link option enter image description here

always sending the last option enter image description here

the filter controller work fine. i believe the problem is in the dropdown menu in blade it doesn't send the option the link

this is my blade

<form action="{{ action('App\Http\Controllers\HomePageController@processForm') }}" method="POST" >
    @csrf
    <input type="hidden" value="alpha" name="sortoption"id="alpha"> 
    <input type="hidden" value="desc" name="sortoption" id="desc">
    <input type="hidden" value="asc" name="sortoption" id="asc">
                                
    <span >Sort by</span>
    <span te >Sort by</span>
    <select name="orderby"  aria-label="Shop order" data->
        <option for="alpha">Ordre Alphabetique</option>
        <option for="desc">Prix Decroissant</option>
        <option for="asc">Prix Croissant</option>
    </select>
</form>

CodePudding user response:

Your syntax for <option> is wrong. for is an attribute used in <label> tags. The attribute to set an option's value is value.

You do not need the hidden inputs either.

<form action="{{ action('App\Http\Controllers\HomePageController@processForm') }}" method="POST" >
    @csrf
    <span >Sort by</span>
    <span >Sort by</span>
    <select name="sortoption"  aria-label="Shop order" data->
        <option value="alpha">Ordre Alphabetique</option>
        <option value="desc">Prix Decroissant</option>
        <option value="asc">Prix Croissant</option>
    </select>
</form>
  •  Tags:  
  • Related