david19
3 months ago
246
2
Laravel

Form checked @if

Posted 3 months ago by david19

My forms works great. But for my edit view, the checked mark doesnt work.

I have a relationship Product with Categories.

If the Category_id ( Table:Products) , same as ID (Table:Categories), it should be checked! This not work..

@foreach ($categories as $category)
<label>
<input type="radio" name="category_id" id="optionsRadios1" value="{{$category->id}}" @if ($product->category_id == $category->id) checked @endif>
</label>
{{ $category->name }}
<br>
@endforeach

Please sign in or create an account to participate in this conversation.