function listObjects() { if (Form::submitted()) { $operation = Form::filtered('operation'); list($object_id, $method) = each($operation); if (method_exists($this, $method)) { $this->{$method}($object_id); } else { trigger_error(__CLASS__ . "::{$method} does not exists"); } } $objects = $this->dbQuery('select id, name, comment, protected from t_objects'); foreach ($objects as $object) { /* there are several dufferent ways to put data into * the form elements, but you could use the way below: */ Form::choose()->set('name/value', $object['name'])->set('comment/value', $object['comment'])->set('protected/checked', $object['protected'] ? 'checked' : null); echo "<!-- {$object['id']} -->\n"; // output name & comment foreach (Form::fieldsetIDs('fieldset1') as $control_id) { echo Form::label(array($control_id, $object['id'])); foreach (Form::message($control_id) as $message) { echo "<p class=error>{$message}</p>"; } echo Form::control(array($control_id, $object['id'])); } // output checkbox, if it's for example optional echo Form::checkbox(Form::attrs(array('protected', $object['id']))); // ouput operation buttons echo Form::button(Form::attrs(array('save', $object['id']))); echo Form::button(Form::attrs(array('delete', $object['id']))); echo "<!-- /{$object['id']} -->\n"; } }