首页 > 解决方案 > I am working on a Laravel 8 project in which I want to keep the old value in select option in the blade file

问题描述

I know this question is asked many time but don't know why solution is not working for me. I am a beginner and have a very simple confusion. I have a form in Laravel blade with a drop down. Now I want to keep the drop down value selected after the user submit the form. This is the code I applied to make it work from internet but don't know why it is not working.

<select class="form-control" name="company">
    <option value="select">Select Type</option>
    <option value="Apple" {{ old('company') == "Apple" ? 'selected' : '' }}>Apple</option>
    <option value="Google" {{ old('company') =="Google" ? 'selected' : '' }}>Google</option>
    <option value="Mi" {{ old('company') == "Mi"? 'selected' : '' }}>Mi</option>
    <option value="Samsung" {{ old('company') == "Samsung" ? 'selected' : '' }}>Samsung</option>
</select>

标签: phplaravellaravel-bladelaravel-8

解决方案


推荐阅读