Esempio n. 1
0
 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";
     }
 }
Esempio n. 2
0
<?php

echo \AIIX\Form::control('a');
echo \AIIX\Form::control('b');
// out of formdata
echo \AIIX\Form::control('x');
echo \AIIX\Form::control('z');
// out of formdata, no post data
echo \AIIX\Form::control('select.0');
echo \AIIX\Form::control('select.1');
echo \AIIX\Form::control('comment.0');
// no post data
echo \AIIX\Form::control('comment.1');
// post data provided
echo \AIIX\Form::checkbox(\AIIX\Form::attrs('c'));
echo \AIIX\Form::checkbox(\AIIX\Form::attrs('c1'));
// out of formdata, no post data
for ($_i = 1; $_i <= 4; ++$_i) {
    echo "\n";
    echo \AIIX\Form::control("checkbox{$_i}.0");
    // no post data
    echo \AIIX\Form::control("checkbox{$_i}.1");
    // post data provided
}