I am using quite a large form to create an array of genetics a gecko carries.
I have posted it below for reference:
<form method="POST" action="/geckos" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" name="user_id" id="user_id" value="{{ Auth::user()->id }}">
<div class="form-group">
<label for="name">Gecko Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Name" value="{{ Request::old('name') }}">
</div>
<div class="form-group">
<label for="aquisition_date">Aquisition Date</label>
<input type="date" class="form-control" name="aquisition_date" id="aquisition_date" placeholder="Date" value="{{ Request::old('aquisition_date') }}">
</div>
<div class="form-group">
<label for="morph">Gecko Morph Title</label>
<input type="text" class="form-control" name="morph" id="morph" placeholder="Eg. White & Yellow Mack Snow Raptor" value="{{ Request::old('morph') }}">
</div>
<div class="form-group">
<label for="sex">Gecko Sex</label>
<?php $options = array('Female' => 'Female', 'Male' => 'Male', 'Temp Sexed Female' => 'Temp Sexed Female', 'Temp Sexed Male' => 'Temp Sexed Male'); ?>
{!! Form::select('sex', $options, Input::old('sex'), array('class' => 'form-control')) !!}
</div>
<div class="row">
<div class="col-md-12">
<h3>Recessives</h3>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Bell Albino</label>
<?php $options = array('na' => 'N/A', 'BA' => 'Visual', 'ba' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Rainwater Albino</label>
<?php $options = array('na' => 'N/A', 'RW' => 'Visual', 'rw' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Tremper Albino</label>
<?php $options = array('na' => 'N/A', 'TA' => 'Visual', 'ta' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Murphy's Patternless</label>
<?php $options = array('na' => 'N/A', 'MP' => 'Visual', 'mp' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Eclipse</label>
<?php $options = array('na' => 'N/A', 'EC' => 'Visual', 'ec' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Marble Eye</label>
<?php $options = array('na' => 'N/A', 'ME' => 'Visual', 'me' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Blizzard</label>
<?php $options = array('na' => 'N/A', 'B' => 'Visual', 'b' => 'Recessive'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Snows</h3>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Mack Snow</label>
<?php $options = array('na' => 'No', 'MS' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Super Snow</label>
<?php $options = array('na' => 'No', 'SS' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Gem Snow</label>
<?php $options = array('na' => 'No', 'GS' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="genetics">TUG Snow</label>
<?php $options = array('na' => 'No', 'TS' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="genetics">Line Bred Snow</label>
<?php $options = array('na' => 'No', 'LBS' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Dominants</h3>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="genetics">Enigma</label>
<?php $options = array('na' => 'No', 'EN' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="genetics">White & Yellow</label>
<?php $options = array('na' => 'No', 'WY' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="genetics">Wildtype</label>
<?php $options = array('na' => 'No', 'WT' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="genetics">Giant</label>
<?php $options = array('na' => 'No', 'G' => 'Yes'); ?>
{!! Form::select('genetics[]', $options, Input::old('genetics[]'), array('class' => 'form-control')) !!}
</div>
</div>
</div>
<div class="form-group">
<label for="bio">Gecko Bio</label>
<textarea class="form-control" rows="3" name="bio" id="bio" placeholder="Bio">{{ Request::old('bio') }}</textarea>
</div>
<div class="form-group">
<label for="bred">Gecko Bred?</label>
<div class="radio">
<label>
<input type="radio" name="bred" id="bredYes" value="1" @if(Request::old('bred')) checked @endif>
Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="bred" id="bredNo" value="0" @if(Request::old('bred')) checked @endif>
<input type="radio" name="bred" id="bredNo" value="0" @if(!Request::old('bred')) checked @endif>
No
</label>
</div>
</div>
<div class="form-group">
<label for="hatchling">Gecko Hatchling?</label>
<div class="radio">
<label>
<input type="radio" name="hatchling" id="hatchlingYes" value="1" @if(Request::old('hatchling')) checked @endif>
Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="hatchling" id="hatchlingNo" value="0" @if(Request::old('hatchling')) checked @endif>
<input type="radio" name="hatchling" id="hatchlingNo" value="0" @if(!Request::old('hatchling')) checked @endif>
No
</label>
</div>
</div>
<div class="form-group">
<label for="clutch">Gecko Clutch</label>
<input type="text" class="form-control" name="clutch" id="clutch" placeholder="Clutch ID" value="{{ Request::old('clutch') }}">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Create Gecko</button>
</div>
</form>
I'm saving the array to the database like this: ["BA","na","na","na","EC","na","na","na","na","na","na","na","na","na","na","na"]
Now the Request::old()
function works fine if there's an error in the form etc. But I'm just wondering if this is still going to work when trying to load it into an edit view or if i need to do something else in order for this array to show properly?
Thanks for your time, Andy
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire