[pmwiki-users] Multiple checkboxes
Petko Yotov
5ko at 5ko.fr
Mon Sep 21 18:12:23 CDT 2015
There has been a change in May allowing setting and posting multiple
checkboxes in some cases. See how to use it here:
http://www.pmwiki.org/wiki/PITS/01032
I believe Fox was also updated to handle those.
The current way to do this would be to set multiple default values,
separated by spaces, like:
your PageTextVariable (PTV):
(:Hobby:Travels Music:)
in the form:
(:input default $:Hobby[] {$:Hobby}:)
(:input checkbox $:Hobby[] Travels:) Travels
(:input checkbox $:Hobby[] Photography:) Photography
(:input checkbox $:Hobby[] Music:) Music
No need to have (:if matchstring...:).
Note that a PTV cannot set multiple-checkboxes directly with (:input
default source={$FullName}:), as there is no PTV "$:Hobby[]" with
brackets, the PTV is "$:Hobby". That's why I set a default value as an
intermediate step: (:input default $:Hobby[] {$:Hobby}:)
At the time I asked people to test and report any problems, and for
ideas how to handle things, this is still possible.
Petko
On 2015-09-21 23:35, kirpi at kirpi.it wrote:
> Setting a form with multiple checkboxes and storing a comma separated
> list of hobbies (just an example) in a ptv proved to be a little
> tricky, but many months ago I found that this approach works just
> fine:
>
> ''Hobby:'''\\
> (:input hidden name=$:Hobby "":)
> (:input checkbox $:Hobby[] Travels (:if matchstring '/Travels/'
> "{{$FullName}$:Hobby}":)checked(:ifend:):) Travels\\
> (:input checkbox $:Hobby[] Photography (:if matchstring
> '/Photography/' "{{$FullName}$:Hobby}":)checked(:ifend:):)
> Photography\\
> (:input checkbox $:Hobby[] Music (:if matchstring '/Music/'
> "{{$FullName}$:Hobby}":)checked(:ifend:):) Music
>
> Actually, it did work until recently :-(
>
> Now, for some reason, it does not work any longer: if I edit the form
> (I use Fox) a second time, all the data are reset.
> Is it perhaps due to some changes in the latest version of Pmwiki?
--
Change log : http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes : http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade : http://www.pmwiki.org/wiki/PmWiki/Upgrades
More information about the pmwiki-users
mailing list