By default a radio type input will only be set if it's set to something other than false/0. You will need to do a check for that.
You can get around this by using yes/no as the values. Or setting a default if it's not set
$request->input('name', 0);
Hi! I have a form that lists mulptiple photographers for an event. The form hold information about the cost to pay each photographer, along with a note and if a specific photographer is paid or not (the radio button, yes/no). Since the number of photographers for a given event is ambigous, I have the form field names defined as arrays so I iterate trough the amount of added photographers and update their fields accordingly.
This is the snippet of the form I'm describing:
@foreach($event_photographers as $key => $photographer)
<div class="row" style="margin-bottom:10px;">
<div class="col-xs-3">
<h5><i class="fa fa-user"></i> Fotograf {{ $event_photographers->count() >1 ? $key+1 : '' }}</h5>
{{ $photographer->getFullnameAttribute() }}
</div>
<div class="col-xs-3">
<i class="fa fa-money"></i> {{ Form::label('photographer_payment_sum', 'Arvode') }}
{{ Form::text('photographer_payment_sum[]', $photographer->pivot->photographer_payment_sum, array('class' => 'form-control', 'placeholder' => 'Arvode i kronor', 'autocomplete' => 'off')) }}
{{ $errors->first('photographer_payment_sum[]', '<span class="text-danger">:message</span>') }}
</div>
<div class="col-xs-4">
<i class="fa fa-pencil"></i> {{ Form::label('photographer_payment_notes', 'Kommentar') }}
{{ Form::text('photographer_payment_notes[]', $photographer->pivot->photographer_payment_notes, array('class' => 'form-control', 'placeholder' => 'Kommentar', 'autocomplete' => 'off')) }}
{{ $errors->first('photographer_payment_notes[]', '<span class="text-danger">:message</span>') }}
</div>
<div class="col-xs-2 text-right">
{{ Form::label('photographer_is_paid', 'Fått betalt?') }}<br/>
<div class="btn-group" data-toggle="buttons">
<label id="photographer_is_paid_true" class="btn btn-default {{ $photographer->pivot->photographer_is_paid ? 'active' : '' }}">
<input type="radio" name="photographer_is_paid[]" value="1" {{ $photographer->pivot->photographer_is_paid ? 'checked' : '' }}> Ja
</label>
<label id="photographer_is_paid_false" class="btn btn-default {{ !$photographer->pivot->photographer_is_paid ? 'active' : '' }}">
<input type="radio" name="photographer_is_paid[]" value="0" {{ !$photographer->pivot->photographer_is_paid ? 'checked' : '' }}> Nej
</label>
</div>
{{ $errors->first('photographer_is_paid', '<span class="text-danger">:message</span>') }}
</div>
</div>
@endforeach
However, when I post the form I see that I do have multiple values being sent for the note field along with the cost field for each photographer. But the only value I get from the radio buttons is the "true" values. I.e. when the toggle is set to "Ja".
Have any of you run into the same issue before?
If you have multiple radios that each need to be grouped, you may need to set the array number.
name="photographer_is_paid[1]"
name="photographer_is_paid[2]"
Just an idea
Please or to participate in this conversation.