Display option of select as selected with blade directive Laravel
Display option of select as selected with blade directive Laravel
With this article, we will examine several different instances of how to solve the "Display option of select as selected with blade directive Laravel".
Here we have a blade directive `@selected` in Laravel 9 to display the option of select box as selected with condition. Like if we want to display the old value to be selected of the select box which we have selected while submit the form data then `@selected` directive is very helpful to do so.Syntax: @selected(old('version') == $version)
-
<select name="version"> @foreach ($product->versions as $version) <option value="{{ $version }}" @selected(old('version') == $version)> {{ $version }} </option> @endforeach </select>
-
Select option to be selected while creating a record in Laravel using old helper method
<option value="{{ $company->id }}" @if(old('company') == $company->id) selected @endif> {{ $company->name }} </option>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to add dynamic page title in Laravel view
- How to add active class to menu item in laravel
- How to get all route list
- Method Illuminate\Events\Dispatcher::fire does not exist
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- Laravel upload file with original file name
- Include External CSS and JS file in Laravel
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to get tomorrow and yesterday date in laravel
- Permission denied error while creating storage link in Laravel
- How to add unique records in pivot columns of Laravel pivot table
- Touch parent updated_at in Laravel
- How to get route method name in Laravel
- Add class to body in laravel view
- Laravel 11 project setup on localhost using breeze with blade step by step
- How to check if user has created any post or not in laravel
- How to disable timestamps in laravel
- Trying to access array offset on value of type null error in laravel
- Extra Filter Query on Relationships in Laravel
- Store logged in user details in session and display in view in laravel
- Session Doesn't Work on Redirect
- Get last year created records in Laravel
- Laravel clone model
- Extract only time from datetime in laravel