[phplib] OOHForms process From: Hellekin O. Wolf (hellekin <email protected>)
Date: 07/26/00

Hello ppl !

I'm looking for working examples of forms using OOHForms that do the
following :

1. Display a form
2. Validate data and return the form with correct fields frozen,
incorrect fields with an error string above
3. Process data if all is ok, then return a result page

The documentation is quite obscure and I don't know how to use the
self_* methods.

Right now I'm passing the following code :

$f->new Form;

$field["field_name"] = array(
        "type" => "text",
        "name" => "field_name"
        [...]
);
$f->add_element($field["field_name"]);

[...]

$f->show_element("field_name");

[...]

if ($submit) {
        // Validate elements
        $f->start();
        while (list($k,$v) = each($HTTP_POST_VARS)) {
                if ($err = $f->validate(FALSE,array($k,$v))) {
                        // Display error and the field again
                             echo "<p><font color=\"#ff3300\">Error :
$err</font></p>\n";
                        $f->add_element($field[$k]);
                        $f->show_element($k);
                } else {
                        // display the frozen element
                        $f->add_element($field[$k]);
                        $f->freeze(array($k));
                        $f->show_element($k,$v);
                 }
        }
        $f->finish();
} else {
        // Display empty Form
[...]
}

The problem is that the frozen items don't get the field value and
display an empty table.

Thanks

hellekin

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>