
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
- Laravel 9 pagination with search filter
- Route [password.request] not defined
- Method Illuminate\Http\Request::validated does not exist
- How to fetch single row data from database in laravel
- Session Doesn't Work on Redirect
- Get id of last inserted record in laravel
- Method Illuminate\Events\Dispatcher::fire does not exist
- Trying to access array offset on value of type null error in laravel
- How to create static page in Laravel
- How to create projects method with belongstomany relationship in user model
- Route not defined in Laravel
- How to pass variable from controller to model in Laravel
- Insert data with form validation using ajax in laravel
- Array to string conversion laravel blade
- Cannot end a section without first starting one
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- Laravel specific table Migration
- Page loader in laravel
- How to get laravel errors folder in views directory in laravel
- Laravel route parameter
- Add a subselect based on relationship using withAggregate method
- How to display validation error in laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- Retrieve count of nested relationship data in Laravel
- How to set column as primary key in Laravel model