Sunday, April 2, 2017

Populate select dropdown if returning with errors

As with my text fields, if an error is returned on the view, I want to populate the select elements with the previously submitted data, like: value="".

Current view:

<select class="form-control" id="input" name="" required="required">
    <option disabled selected value> -- Select an option --</option>
        @foreach($answers as $answer)
            <option value=""></option>
        @endforeach
</select>

How can I implement it into the above scenario, as there doesn't seem to be a place where I can add a value without overwriting one? Thank you.



via Ben

Advertisement