[pmwiki-users] Setting input defaults for checkbox arrays

kirpi at kirpi.it kirpi at kirpi.it
Sat Dec 27 16:28:26 CST 2014

Checkbox arrays are useful, yet I recently had a few issues setting
input defaults.
Adding "checked" at the end of any input field, paired with a
conditional, appears to solve the matter.
An hidden input at the top takes care of the case when no checkbox is checked.
Here is a working example using the "matchstring" conditional[1] and Fox:

(:fox testform ptvtarget={$FullName} ptvclear=1:)
(:input hidden Hobby "":)
(:input checkbox Hobby[] Reading (:if matchstring '/Reading/'
"{$:Hobby}":)checked(:ifend:):) Reading
(:input checkbox Hobby[] Climbing (:if matchstring '/Climbing/'
"{$:Hobby}":)checked(:ifend:):) Climbing
(:input checkbox Hobby[] Music (:if matchstring '/Music/'
"{$:Hobby}":)checked(:ifend:):) Music
(:input checkbox Hobby[] Sleeping (:if matchstring '/Sleeping/'
"{$:Hobby}":)checked(:ifend:):) Sleeping
(:input checkbox Hobby[] Chess (:if matchstring '/Chess/'
"{$:Hobby}":)checked(:ifend:):) Chess
(:input checkbox Hobby[] Gardening (:if matchstring '/Gardening/'
"{$:Hobby}":)checked(:ifend:):) Gardening
(:input submit post enter:)
(:foxend form:)

I am not sure this is properly documented in the pmwiki.org website
yet, so I just entered a few lines about it and the example above on
the InputDefault-Talk page.



[1] http://www.pmwiki.org/wiki/Cookbook/ConditionalMarkupSamples
[2] http://www.pmwiki.org/wiki/Cookbook/InputDefault-Talk

More information about the pmwiki-users mailing list