What’s the correct mark-up for custom radios and server-side validation?
Created by: martinbean
I’m having trouble rendering stacked custom radios with server-side validation.
My raw mark-up looks like this (a Laravel Blade template):
<div class="form-group">
<label class="form-control-label">Category</label>
<div class="custom-controls-stacked">
@foreach($categories as $id => $name)
<label class="custom-control custom-radio">
<input type="radio" id="category-{{ $id }}" name="category_id" value="{{ $id }}" class="custom-control-input" {{ old('category_Id') == $id ? 'checked ' : '' }}/>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">{{ $name }}</span>
</label>
@endforeach
</div>
@foreach($errors->get('category_id') as $error)
<div class="invalid-feedback">{{ $error }}</div>
@endforeach
</div>
Where is the appropriate place to put the .is-invalid
class that both makes the radio inputs red, and displays the <div class="invalid-feedback">
elements?