I am using bootstrap, and am trying to convert checkboxes into a button that shows when it is pressed or not(checked or not). If I keep the code showing the checkboxes, it works perfect. If I keep the code as labelled buttons, the "checked" buttons do not load properly(they do save).
Checkbox Code w/checkboxes(That works)
<div class="btn-group" id="salesman" data-toggle="buttons"></div>
<h5>Salesman :</h5>
<?php
$salesman = json_decode($invoice['Invoice']['salesman'], true);
$salesman_names = array(1 => "User1",2 => "User2",3 => "User3",4 => "User4",5 => "User5");
foreach ($salesman_names AS $i => $name) {
if ($salesman[$name] == "checked") {
echo '<label class="btn btn-default"><input type="checkbox" name="data-invoice-salesman[]" value="'.$i.'" checked/> '.$name.'</label>';
} else {
echo '<label class="btn btn-default"><input type="checkbox" name="data-invoice-salesman[]" value="'.$i.'" /> '.$name.'</label>';
}
}
?>
Checkbox Code w/out Checkboxes(that needs fixed?)
<div class="btn-group" id="salesman" data-toggle="buttons">
<h5>Salesman :</h5>
<?php
$salesman = json_decode($invoice['Invoice']['salesman'], true);
$salesman_names = array(1 => "User1",2 => "User2",3 => "User3",4 => "User4",5 => "User5");
foreach ($salesman_names AS $i => $name) {
if ($salesman[$name] == "checked") {
echo '<label class="btn btn-default"><input type="checkbox" name="data-invoice-salesman[]" value="'.$i.'" checked/> '.$name.'</label>';
} else {
echo '<label class="btn btn-default"><input type="checkbox" name="data-invoice-salesman[]" value="'.$i.'" /> '.$name.'</label>';
}
}
?>
Aucun commentaire:
Enregistrer un commentaire