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 display HTML tags In Laravel blade
- Shorter syntax for whereHas with call back function in laravel
- How to display order by null last in laravel
- How to get count of all records created at yesterday
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- How to create laravel project using composer
- Method Illuminate\Events\Dispatcher::fire does not exist
- How to Access Array in blade laravel
- Laravel 10 Breeze Authentication Example
- How to delete record in Laravel with ajax
- How to get specific columns using Laravel eloquent methods
- Use withCount() to get total number of records with relationship
- How to get path from current URL in Laravel
- Laravel csrf token mismatch for ajax POST Request
- How to get last month records in Laravel
- Get domain name in laravel
- How to get file extension from input type file in laravel
- How to pass query string with pagination in laravel
- How to send email in Laravel 11
- How to customize or Change validation error messages
- Redirect to another view from controller in laravel
- Insert values in pivot table dynamically in laravel
- How to check records exist in loaded relationship in Laravel blade view
- The use statement with non-compound name 'DB' has no effect
- The Pusher library requires the PHP cURL module. Please ensure it is installed