My way:
(zakładam, ze w strukturze rekordu masz pola reprezentujące flagi dla checkbox'a - jeżeli nie, obiekt się nie zmienia, po prostu dobierz foreach w inny sposób)
<?php
public class CheckBox {
public isChecked = false;
// szablonik:
private template = '<input type="checkbox" name="{name}" {checked}/>';
public function CheckBox($name) {
$this->setAttribute('name', $name);
}
public function setChecked() {
$this->checked = true;
}
private function setAttribute($name, $val) {
$this->template = str_replace('{'.$name.'}', $val, $this->template); }
public function draw() {
($this->checked) ? $this->setAttribute('checked', 'checked') : $this->setAttribute('checked', '') ;
}
}
// ------------->
foreach ($recordField as $name => $val) {
// checkbox:
$checkbox = new CheckBox($name);
$checkbox->isChecked = $val;
$checkbox->draw();
// nazwa:
}
}
?>