11-14-2016, 04:37 PM
Yeah...so there are a few ways to do that with foreach loops and stuff like that, but I would manually update the entire row of checkboxes at every update of the user info. I think it's simpler.
I would do something like (assuming you have your db showing 1 for checked and 0 for unchecked)
Or something like this. This way, you are checking the value of over_18 every time they are updating.
I'm guessing the other part you want to know how to do is to pre-check the boxes... that would be...
Note that the last 2 lines are all technically one line
I would do something like (assuming you have your db showing 1 for checked and 0 for unchecked)
Code:
$over_18 = Input::get('over_18');
Code:
if ($over_18 === 1) {
Code:
$over_18 = "1";
Code:
} else {
Code:
$over_18 = "0";
Code:
}
I'm guessing the other part you want to know how to do is to pre-check the boxes... that would be...
Code:
<input type='checkbox' name='over_18' id='over_18' value='1' <?php if ($user->data()->over_18 == '1')
Code:
echo "checked='checked'"; ?>> Are you over 18?
Note that the last 2 lines are all technically one line