I'm having a problem to align four checkboxes in each row with the code below. Any solution?
<div class="form-group">
<div class="row">
<label for="form-id" class="col-sm-4 col-xs-4 control-label">그룹</label>
<div class="col-sm-8 col-xs-8">
<?php foreach ( $memberGroupList as $memberGroup ) { ?>
<div class="col-lg-4 col-sm-6 col-xs-12">
<?php if (in_array($memberGroup->getId(),$arrMemberMemberGroup)) { ?>
<input class="form-check-input" type="checkbox" name="memberGroupId[]" value="<?php echo $memberGroup->getId()?>" checked > <?php echo $memberGroup->getName()?>
<?php } else { ?>
<input class="form-check-input" type="checkbox" name="memberGroupId[]" value="<?php echo $memberGroup->getId()?>" > <?php echo $memberGroup->getName()?>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
My Answer:
To align the checkboxes in a row and continue on a new line after every 4 checkboxes, you can modify your code as follows:
php
$counter = 0;
foreach ($memberGroupList as $memberGroup) {
if ($counter % 4 == 0) {
echo '';
}
?>
getId(), $arrMemberMemberGroup)) { ?>
getName() ?>
getName() ?>
$counter++;
if ($counter % 4 == 0) {
echo '';
}
}
if ($counter % 4 != 0) {
echo '';
}
?>
Rate this post
3 of 5 based on 7955 votesComments