I am having trouble wrapping my head around how to validate a form I have created. The form I have looks something like this:
<input id="box-1-nickname" name="box-1-nickname" class="form-control" type="text" placeholder="Required">
<select id="box-1-destination" name="box-1-destination" class="form-control">
<option value="store">Storage Facility</option>
<option value="ship">Ship</option>
</select>
<input class="box-height form-control" id="box-1-height" name="box-1-height" type="number" placeholder="in Inches">
<input class="box-width form-control" id="box-1-width" name="box-1-width" type="number" placeholder="in Inches">
<input class="box-depth form-control" id="box-1-depth" name="box-1-depth" type="number" placeholder="in Inches">
<input class="box-weight form-control" id="box-1-weight" name="box-1-weight" type="number" placeholder="in Pounds">
<label class="radio-inline">
<input id="box-1-size-retail" name="box-1-size" type="radio" value="retail" checked>
Retail box (18" x 18" x 22")
</label>
<label class="radio-inline">
<input id="box-1-size-custom" name="box-1-size" type="radio" value="custom">
I'll use my own box
</label>
The part that complicates it a bit is the fact that a user can 'add a box' which will duplicate these form fields and increment the box ID by 1. After adding/removing a few boxes and submitting the form the Input::all() might come back looking something like this:
array (size=29)
'box-1-nickname' => string 'Something' (length=9)
'box-1-destination' => string 'store' (length=5)
'box-1-height' => string '1' (length=1)
'box-1-width' => string '2' (length=1)
'box-1-depth' => string '3' (length=1)
'box-1-weight' => string '4' (length=1)
'box-1-size' => string 'retail' (length=9)
'box-4-nickname' => string 'Another' (length=7)
'box-4-destination' => string 'ship' (length=4)
'box-4-height' => string '33' (length=2)
'box-4-width' => string '1' (length=1)
'box-4-depth' => string '22' (length=2)
'box-4-weight' => string '33' (length=2)
'box-4-size' => string 'custom' (length=6)
'box-6-nickname' => string 'Stuff' (length=5)
'box-6-destination' => string 'store' (length=5)
'box-6-height' => string '34' (length=2)
'box-6-width' => string '76' (length=2)
'box-6-depth' => string '44' (length=2)
'box-6-weight' => string '2' (length=1)
'box-6-size' => string 'retail' (length=9)
'box-8-nickname' => string 'Things and others' (length=17)
'box-8-destination' => string 'ship' (length=4)
'box-8-height' => string '5' (length=1)
'box-8-width' => string '66' (length=2)
'box-8-depth' => string '5' (length=1)
'box-8-weight' => string '33' (length=2)
'box-8-size' => string 'custom' (length=6)
'_token' => string 'BIXSdz16ccJLaOmTxh2ShW5C16W1g0xmpJ10xnwC' (length=40)
I'm struggling to find a way to validate these box inputs since I don't really know how many box fields would be submitted or what their input names would be. Any suggestions would be very welcome.