
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 use more than one query scope in Laravel
- Get all users except the followings users in overtrue laravel-follow
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- How to get all route list
- Pagination in laravel
- Target class [HomeController] does not exist
- Laravel create multiple records in Pivot table
- Update existing pivot table data in laravel
- Laravel URL validation not working
- Laravel append URI in route
- Symlink(): No such file or directory
- How to check find method executed successfully in laravel
- Get latest record by created at in Laravel
- Get the post details if it has at least one comment in comments table
- Show old value while editing the form in Laravel
- Php artisan make model, factory, migration and controller in single command
- How to Get records between two dates in Laravel
- Route not defined in Laravel
- Comment .env file in laravel
- Redirect from www to non www in laravel using htaccess
- Get current month records in laravel 7/8
- How to display pivot table column value in laravel
- Create project table with model and migration
- Submit form without CSRF token in Laravel
- How to check duplicate entry in laravel