user4187476
user4187476

Reputation:

Laravel - Request does not contain my inputs

I have the following form :

<div class="container text-center search-container">
    <form id="search-form" action="" method="post">
        <div class="nopadding col-xs-12 col-sm-2">
            <select name="huge" class="form-control input-block-level selectpicker search-selector" data-style="btn-default btn-fill btn-block">
                <option disabled>Search in...</option>
                <option value="1" selected>foo1</option>
                <option value="2">foo2</option>
                <option value="3">foo3</option>
            </select>
        </div>
        <div class="nopadding col-xs-12 col-sm-8">
            <input type="text" class="form-control input-block-level search-bar" id="searchbar">
        </div>
        {{ csrf_field() }}
        <div class="nopadding col-xs-12 col-sm-2">
            <button class="btn btn-info btn-fill search-button input-block-level" type="submit">Search</button>
        </div>
    </form>
</div>

I use bootstrap-select for the select element.

This calls a method in my controller, however when I do a dd($request->all(), here is what I do obtain :

array:2 [▼
  "huge" => "1"
  "_token" => "somethingReallyLongAndBoring"
]

Basically, I am not able to retrieve my inputs. Any idea what I did wrong ?

Upvotes: 1

Views: 649

Answers (1)

Saumini Navaratnam
Saumini Navaratnam

Reputation: 8850

You have to add name attribute to the input field.

<input type="text" class="form-control input-block-level search-bar" id="searchbar" name="searchbar">

Upvotes: 4

Related Questions