[pmwiki-users] Input form?

Peter & Melodye Bowers pbowers at pobox.com
Wed Feb 20 03:37:03 CST 2008


> > > I am looking for some very simple form: a dozen of checkmark
> > > option, with people can only choose 2 of the dozen available,
> > > with an email of the selected options.
> > >
> > > I have found: (:input checkbox name value:) but where do I do
> > > the validation? any example?
> >
> > Check out
> > http://www.pmwiki.org/wiki/Cookbook/WikiFormsRecipes#query
> 
> Sorry but my php level is 0. Is there any other way than learning
> php for processing the form?

Is the validation you want limited to just what you mentioned above, the
limitation of only 2 out of 12?  If so it'll look a lot like this (this
would be placed in your local directory in a name which exactly matched the
name of the page with the form -- so if you have your form in GroupA.Page1
then the PHP file would be named local/GroupA.Page1.php):

<?php
foreach ($_GET as $k=>$v) {
   $foo = htmlspecialchars($v);
   # This keeps the field values current with the form from submission to
   # submission, but has nothing to do with PTV
   $InputValues[$k] = $foo;
   # This creates a PTV
   $FmtPV['$'.$k] = "'$foo'";
}
# Limit the user to a max of 2 checkboxes checked
if ($FmtPV['$field1'] == "'1'") $cnt++;
if ($FmtPV['$field2'] == "'1'") $cnt++; 
if ($FmtPV['$field3'] == "'1'") $cnt++;
...

if ($cnt > 2) {
	$MessageFmt[] = "ERROR: Too many boxes checked.  You may only use
2";
	#Then you've got to make sure whatever action was going to be taken
doesn't get taken...
}

(DO NOTE that I'm modifying the code found in WikiFormsRecipes#query
off-the-cuff with no testing at all so there's no guarantees of anything
here.)

If you want something that doesn't use PHP at all then you could perhaps
look into fox or pmforms or something like that -- Hans &/or PM will have to
speak to whether they support data validation without PHP coding...

-Peter





More information about the pmwiki-users mailing list