PmWiki | FoxDocumentation / FilterFunctions (original) (raw)
You can preprocess (filter) the posted field values using custom filters. A recipe script can define its own filter function and add it to the $FoxFilterFunctions array like this:
$FoxFilterFunctions['mycustomfilter'] = 'MyCustomFilterFunction'; function MyCustomFilterFunction($pagename, $fields) { ...process any field values here.... return $fields; }
Then a Fox form can call the filter function with parameter foxfilter=mycustomfilter or as a hidden input control of form (:input hidden foxfilter mycustomfilter :)
Fox will use a series of filters in the specified order if several filter function names are given, like
foxfilter="filterA,filterB,filterC"
Additional examples of filters can be found in Cookbook:Fox-FilterExamples
If you do multi-page processing, or multi-target processing (like posting to different sections on a target page and using different templates for such), then sometime sit may be required that under certain input conditions a specific target process should be skipped, rather than the whole process be aborted. foxaction='skip' can be used for such. Use in a conditional loop to insert for the correct target. Example code snippet, which checks for a condition in foxtemplates
foreach($fx as key=>key => key=>val) { ...... foreach ($fx[':foxtemplate'] as i=>i => i=>tmpl) { if (strstr($tmpl, $key)) fx[′:foxaction′][fx[':foxaction'][fx[′:foxaction′][i] = "skip"; ...........