Date: 07/26/00
- Next message: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Previous message: Eduardo Mena: "RE: [phplib] Error message"
- In reply to: Hellekin O. Wolf: "[phplib] OOHForms process"
- Next in thread: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Reply: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Hellekin O. Wolf" wrote:
> 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
Just wait another decade for the new code...
> The documentation is quite obscure and I don't know how to use the
> self_* methods.
Obscure - hmm the code is obscure but not the docs. It's sometimes 100%
OO, sometimes not. The name of the self_* function for example is
confusing. Instead of defining "abstract" functions show(),
show_frozen() and so on he defined self_show, self_show_frozen etc.
This would be pure OO (as far as possible in PHP):
class foo {
function show() { die(); }
function show_frozen() { die(); }
}
class bar extends foo {
function show() {
[your code goes here]
}
function show_frozen() {
[your code goes here]
}
}
Instead of this way the author choosed to define self_* function in
several files where the self_ indicates that you can override it with
you own functionality.
>
> 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
> [...]
> }
Sorry, I do not understand your code. You should call add_element()
first to define you form elements, then call validate() for each one and
finally decide wether to call freeze() or not before calling
show_element().
By the way it's not a good style to loop trough $HTTP_POST_VARS.
Ulf
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Previous message: Eduardo Mena: "RE: [phplib] Error message"
- In reply to: Hellekin O. Wolf: "[phplib] OOHForms process"
- Next in thread: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Reply: Hellekin O. Wolf: "Re: [phplib] OOHForms process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

