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
- Call to a member function pluck() on array
- Laravel 9 pagination with search filter
- Database transactions in laravel
- How to get all route list
- How to access the nth object from Laravel collection object ?
- How to get route name on visit URL in laravel
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- 419 page expired error in Laravel
- Input file with max size validation in laravel
- How to get count of all records created at yesterday
- How to get tomorrow and yesterday date in laravel
- How to automatically update the timestamp of parent model in Laravel
- SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
- How to insert dynamic value to additional column in pivot table in laravel
- Display message with session flash using bootstrap alert class in laravel
- How to create projects method with belongstomany relationship in user model
- How to use bootstrap pagination in laravel 8
- Pass value from controller to model in laravel
- How to print form data in laravel
- Route [password.request] not defined
- Seed database using SQL file in Laravel
- Rendering HTML from database table to view in Laravel
- Retain selected value of select box in Laravel
- How to get session in blade Laravel ?
- Delete file from amazon s3 bucket using Laravel