DEV Community

Sospeter Mong'are
Sospeter Mong'are

Posted on

2

Display dropdown in blade in laravel

<div class="form-group">
<label for="category_id">Transaction category</label>
<select class="form-control" id="category_id" name="category_id" required>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ $transaction->category_id == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
</div>

Top comments (1)

Collapse
 
limon96 profile image
Limon96

You can do it like this:

<option value="{{ $category->id }}" @selected($transaction->category_id == $category->id)>
{{ $category->name }}
</option>
Enter fullscreen mode Exit fullscreen mode

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more