When you use a textarea field and enter multiple lines the table breaks once it is saved. e.g.)
%EDITTABLE{format="textarea, 3x10"}%
| foo |
| bar |
Here's a bit of a hack I made to fix this, but I'm sure it can probably be done in a nicer manner.
It basically replaces linefeeds with
when saved and when editing the table the
is replaced with the linefeeds again to make it convenient for the user.
--- EditRowPlugin/TableCell.pm 2007-11-27 16:31:49.000000000 -0800
+++ EditRowPlugin/TableCell.pm 2007-11-27 17:23:56.000000000 -0800
@@ -35,6 +35,13 @@
sub stringify {
my $this = shift;
+ my $text = $this->{text};
+
+ # modify to replace linefeeds with breaks to support multiline textareas
+ $text =~ s/[\r\n]+/<br>/g;
+
+ $this->{text} = $text;
+
return $this->{precruft}.$this->{text}.$this->{postcruft};
}
@@ -170,12 +177,17 @@
$rows = 3 if $rows < 1;
$cols = 30 if $cols < 1;
+ # modify textarea to display multiple lines nicely
+ my $tmptext = $unexpandedValue;
+ $tmptext =~ s/<br>/\r\n/gi;
+ $tmptext =~ s/\%BR\%/\r\n/gi;
+
$text = CGI::textarea({
class => 'EditRowPluginInput',
rows => $rows,
columns => $cols,
name => $cellName,
- value => $unexpandedValue});
+ value => $tmptext});
} elsif( $colDef->{type} eq 'date' ) {
--
TWiki:Main.JeffCrawford
Thanks Jeff, I took the patch in almost verbatim. Seems to work fine.
--
CrawfordCurrie - 08 Mar 2008