欢迎各位兄弟 发布技术文章
这里的技术是共享的
这是我所描述的形式的片段:
@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
然而,当我发布表单时,我看到我有多个值被发送到笔记字段以及每个摄影师的成本字段。但是,从单选按钮获得的唯一值就是“true”值。当切换设置为“Ja”时。
有没有人遇到同样的问题?
感谢您的回复,但似乎无法正常工作。
在我的情况下,我有四个摄影师,除了我也有四个单选按钮,我会得到四个值的所有属性。
这是我得到的帖子值。正如你所看到的,我拥有的所有数组中有四个值,除了单选按钮值(photographer_is_paid []),我只有一个。在这种情况下,所有单选按钮都切换到“否”:
photographer_ids[]:1
photographer_ids[]:5
photographer_ids[]:6
photographer_ids[]:7
photographer_payment_sum[]:
photographer_payment_notes[]:
photographer_payment_sum[]:
photographer_payment_notes[]:
photographer_payment_sum[]:
photographer_payment_notes[]:
photographer_payment_sum[]:
photographer_payment_notes[]:
photographer_is_paid[]:no