Checkbox Inserts
I have three checkboxes below. And then I have what I think the input into the database should be but its not working. I don't think I have it right. Can someone help please? Any number can be checked except none of them. At least one needs to be checked.
<input type="checkbox" name="clergy[]" value="Spiritual Director" />
<input type="checkbox" name="clergy[]" value="Lay Team" />
<input type="checkbox" name="clergy[]" value="Wherever Needed" />
$teamapp->clergy = $request->input('clergy[]');
Just loop, or single checkboxes.
When you $request->input('clergy'), it's an array.
If you have 4 choices a,b,c,d.
If user checked b,d, then loop, get b.d, store in your related table, or store as json.
Honest, this has been covered many times, either store as related data in a related table or store a json array or a comma separated list.
$testarray = $request->input('clergy');
$mydata = implode(",", $testarray);
Store ---- done
Please or to participate in this conversation.