[pmwiki-users] Struggling with Cookbook/WikiForms

Ben Stallings ben at interdependentweb.com
Fri Mar 2 10:39:55 CST 2007

Francis Casson wrote:
>  I have Cookbook/WikiForms installed and working.  3 questions I hope
> someone can hlep with.

I'm surprised someone else didn't beat me to it!

> 1)  I would like to use one or more fields in conjunction with wiki
> Categories - I know there is a category feild type which inserts the
> category markup around [[!whatevertext]] from a textbox, but I want to use a
> multi-option radio button (Cat1:Cat2:Cat3:Cat4) to force the user to choose
> from predefined categories- which will then and inserts the [[! ]] markup
> around the chosen categories.

I'm not familiar with the WikiForms recipe ... is John Rankin (who wrote 
it) lurking on this list?

But... if you were using Cookbook/ZAP instead, you would write:

  (:if !equal {$cat}:)
  You are using [[!{$cat}]]
  (:if equal {$cat}:)
  The category has not yet been defined.
  Please select your cabling standard:
  (:input radio cat Cat3:) Category 3 (10 Mb/s)
  (:input radio cat Cat5e:) Category 5e (100 MB/s - 1 Gb/s)
  (:input radio cat Cat6:) Category 6 (250 MHz)
  (:input radio cat Cat7:) Category 7 (600 Mhz)
  (:input submit:)

Not sure what you mean by "multi-option radio button" -- by definition 
only one radio button in a set can be selected at a time; if you want to 
allow people to select more than one you need checkboxes instead.  It 
looks like this is the bit in WikiForms you're looking for:

  (value1:value2:...) colons produce a set of checkboxes with none
  selected; any with a leading * are checked for new pages;
  (!value1:value2:...) applies category markup [[!valuen]] to any

> 3) How can you get the checkbox form element to output 'No' if it is not
> checked?

To my knowledge, it can't be done in any of the HTML/XHTML standards to 
date.  Not only can't checkboxes be made to output a value when they're 
unchecked, they don't even submit a null value: they don't show up in 
the form output at all!  For example, a form like this:

  (:input form action=http://example.com method=get:)
  (:input checkbox foo bar:) foo?
  (:input submit:)
  (:input end:)

will output http://example.com?foo=bar&submit=submit when the checkbox 
is checked, but when it is not checked, it will simply output 
http://example.com?submit=submit -- no indication that there even was a 
checkbox.  (I used wiki markup in the example, but the same is true if 
you write the form directly in HTML.)

For this reason I added a feature to Cookbook/UpdateForm where you can 
specify that certain fields should be given a null value if no value is 
specified.  But since you're not using UpdateForm, I suggest you use 
radio buttons instead, like so:

  (:input radio foo yes:) foo
  (:input radio foo no checked=checked:) no foo, thanks

Hope this helps a little!  --Ben

More information about the pmwiki-users mailing list