Re: QF rules as notices
| From: | André Temme | Date: | Thu, 22 Apr 2004 11:36:29 +0000 |
| Subject: | Re: QF rules as notices | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12026@lists.php.net to get a copy of this message | ||
Hello Bertrand, hello Alexey,
and think there may be a slight misunderstanding of my needs, I try to
figure it out again with an example:
Think of a form with an textfield for age (one of many form elements).
Because the form is built for a fincance-company, their customers are
normally between 14 and 70 years, but they could be in some rare cases out
of this range. If worker at the bank now fills in a value of 12 years, the
form should display a _message_ (not error) which says s.th. like "are you
really sure?"
This message shall be displayed in two cases:
1. After the first submit
2. As long as their are "real" error messages like "required", which give
back "false" to $form->validate() so that the form will be displayed again.
At the time all errors are worked off and the form can be submitted, the
form shall be submitted and the result page ("data saved") shall be shown.
Exception: Point 1.
Is it now more understandable what I mean?
Javascript is no solution for us, because with most of the clients JS gets
filtered out.
Custom rules could be the solution, but as I understood them, returning true
results in _not_ displaying error messages, or can this be handled?
A feature like my messages could be a good feature vor Quickform itself, for
example in building online questionaires (which is part of my profession)
this is a often asked "nice to have".
Thanks again,
André
> > I'd like to to add kind of notices to my form.
> >
> > If the user submits a value in a field for which this notice is valid,
> the
> > notice should be displayed after the first submit.
> >
> > If the user decides to "ignore" the notice he can now submit.
> >
> > As long as there are real errors added by addRule(), the form shall be
> > displayed with the messages from the errors and the messages from the
> > notices.
> >
> > Can this be done? How? :-)
>
> You definitely won't be able to do this via builtin QuickForm rules.
> Though you can write your own:
> 1) Rule class / callback to add via addRule() / addGroupRule();
> 2) callback for addFormRule().
>
> These should check whether the form is submitted for the second time
> (this is left as the excercise for the reader) and just return true in
> this case.
>
--
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info