I have this code below which is being used with other select boxes to build up a genetics[]
array. This posts fine to the database however I want to put the select box's name along with the value and use it as JSON.
Currently this is the code I have for 2 boxes:
<div class="form-group">
<label for="genetics">Bell Albino</label>
<?php $options = array('na' => 'N/A', 'BA' => 'Visual', 'ba' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Request::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
<div class="form-group">
<label for="genetics">Tremper Albino</label>
<?php $options = array('na' => 'N/A', 'TA' => 'Visual', 'ta' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Request::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
When I hit save, it saves to the database like this:
['BA', 'ta']
for example. Selecting Visual
from the first list and Recessive
from the second.
I'd like to save it as something like this:
['bell-albino':'BA','tremper-albino':'ta']
Is this possible and if so what's the best way to do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire