[pmwiki-devel] Multi-line field with PmForm
DaveG
pmwiki at solidgone.com
Wed Mar 3 22:57:23 CST 2010
When using PmForm it looks like multi-line fields are stored in the base
page with each %0a on a physically separate line, rather than the normal
PmWiki way of storing the entire page text on a single line.
Here's a snip of what I mean. I've edited from the real thing to avoid
email wrapping, but this demonstrates the end effect:
text=(:pmform savedata:)(:name:test
%0amulti
%0aline:)%0a(:email:djg:)%0a
I believe it's caused by the definition of the $PageTextVarPatterns,
since form data saved using an alternate pattern I also use does not
cause this problem.
1] Does it matter that the line is split? I've seen no ill-effects so
far, but I'm not sure.
2] Is there anything obvious about the pattern that would cause a split
at each new line?
'(:var:...:)' => '/(\\(: *(\\w[-\\w]*) *:(?!\\))\\s?)(.*?)(:\\))/s'
----
Test
----
Test this by following the instructions on PmForm/DataForms. On step 2,
use this template which uses a textarea, rather than the one on the page:
[[#dataform]]
(:input pmform target=savedata :)
(:input default source={*$FullName} :)
(:input default request=1 :)
(:messages:)
|| Name:||(:input textarea $:name rows=10 cols=50 :) ||
|| Email:||(:input text $:email size=25 :) ||
(:input submit :)
(:input end:)
[[#dataformend]]
If you now enter some multi-line text, and save, and then view the saved
page you'll see something like:
text=(:pmform savedata:)(:name:test
%0amulti
%0aline:)%0a(:email:djg:)%0a
----
Aside
----
I'm also struggling to understand the pattern:
a) In particular what does (?!\\)) do? It seems to be "A zero-width
negative look-ahead assertion."[1], and so seems to be matching
something not followed by a ) -- I presume it's preventing false :) matches.
b) In the next section \\s?) the closing ) seems to be left hanging.
Obviously it isn't, so what does it match?
~ ~ Dave
[1]
http://perldoc.perl.org/perlre.html#Regular-Expressions#Look-Around-Assertions
More information about the pmwiki-devel
mailing list