[pmwiki-users] can wikiforms use fox form validation?
design5 at softflow.co.uk
Tue Jul 15 09:08:58 CDT 2008
Monday, July 14, 2008, 10:57:12 PM, John Rankin wrote:
> Hans, is there an online example where I can see what this
> functionality looks like in foxforms? And what does it do if
> there are 2 required fields and they are both empty?
Here is a small example, showing the markup source as well:
Basically Fox uses (:foxcheck inputname:) markup, to check the input
from control named 'inputname'.
Multiple (:foxcheck:) markups are allowed, or one can make
a CSV list of field names to be checked in one markup.
One can specify, beyond the default 'is there any input?', various
check rules using match= for string matching including wiki wildcards,
if= for conditional checks and regex= for regular expression checks.
One can specify a specific error message to be displayed.
I decoupled the display of error messages from the (:foxcheck:)
markup. Because of formatting restrictions of the PmWiki (:messages:)
markup I am using a Fox variation: (:foxmessages:). This can be styled
inline with normal wiki styles, i.e. like %red%'''(:foxmessage:)'''
For displaying the validation error associated with a particular
input field, the form name and field name is entered as parameters in
the (:foxmessages:) markup.
This gives complete control over which input fields should be
checked, in what particular manner, and where and in what style
should an error message be displayed.
The checking is not restricted to visible fields, it can be done on
hidden fields, and replacement variables and markup expressions can be
part of the check rules.
Under the bonnet:
The main checking function is FoxInputCheck. Then there are the
markup functions FoxCheckMarkup (for (:foxcheck:)) and FoxDisplayMarkup
Error messages are accumulated in array $FoxMsgFmt, and to keep
an input control name associated with a message the name is used as
key in the array, the message as the value. FoxDisplayMarkup is
clever enough to filter the appropiate message array elements to the
right (:foxmessage formname fieldname:) markup.
More details about all parameters etc here:
More information about the pmwiki-users