[pmwiki-users] Fun with forms - 3 ideas

Petko Yotov 5ko at free.fr
Fri Apr 20 03:27:24 CDT 2007


On Friday 20 April 2007 09:38, Hans wrote:
> Friday, April 20, 2007, 2:05:48 AM, Patrick wrote:
> >> 1. We need some kind of form validation, or at least, a way to write a
> >> function that will intercept the posted data and decide to filter,
> >> sanitize, save it or not.
> >
> > I'm leaving this as recipes for now... but we can also do
> > javascript client-side validation in addition to server-side
> > validation.
>
> Can the new PmWiki form processor have  a hook so recipes can be
> written to add filter functions, for pre-processing fields?

It is already possible to hook it this way:

  array_unshift($EditFunctions, "MyPreProcessor");
  function MyPreProcessor($pagename,&$page,&$new)
  {
    global $EnablePost;
    if (!$EnablePost) return;
    # is there our trigger form field? 'foxfilter' or whatever
    if(! isset($_POST['_prefilter']) ) return;
    $filters = explode(',', $_POST['_prefilter']);
    # Do the pre-processing, ie.:
    foreach($_POST as $key=>$value)
    {
       # test and sanitize
    }
  }

Petko




More information about the pmwiki-users mailing list