I have a table row like so
<tr class='template4'>
<td>
<textarea name='amendsInput[0][addInfo]' id="additionalInput" placeholder='Additional Information' class="form-control noresize"></textarea>
</td>
<td>
<input type="text" name='amendsInput[0][deliveryDate]' placeholder='Deployment Date' class="form-control amendsDate"/>
</td>
<td>
<div class="col-md-12 checkbox checkbox-danger">
<input type="checkbox" value='1' name="amendsInput[0][complete]" class="styled">
<label for="checkbox">
Complete
</label>
</div>
</td>
</tr>
I allow the user to add additional table rows. When they do, the name for each td increases by 1.
In the above, one of my tds is a checkbox. I essentially want to get a true or false for each table row. In my controller I am currently doing
$campaignAmendsInput = Input::get('amendsInput');
dd($campaignAmendsInput);
If I have two table rows, and only check the checkbox in one of these rows, the output is this
array:3 [▼
0 => array:3 [▼
"addInfo" => "Checkbox Checked"
"deliveryDate" => "03-05-2016"
"complete" => ""
]
1 => array:2 [▼
"addInfo" => "Checkbox not checked"
"deliveryDate" => ""
]
]
So where it was checked, complete is set to an empty string, not 1. Additionally, where it was not checked, there is no complete element whatsoever (I really want complete to be set to 0).
How can I get the checkbox passing 1 or 0 whether it is checked or not?
Thanks
Aucun commentaire:
Enregistrer un commentaire