pg_enable_utf8 => 1,
});
} or Abort('Database error', 501, $@);
+$db->abstract->{array_datatypes}++;
my %lang = (
nl => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'nederlands'],
cover => {-label => 'Highlighted', type => 'checkbox'},
grade => {-label => 'Order', type => 'number'},
form => {-label => 'Title'},
- alt => {-label => 'Synonyms'},
+ alt => {-label => 'Synonyms', -multiple => 1},
wptitle => {-label => 'Wikipedia'},
source => {-label => 'Image'},
- thumb => {-label => 'Convert options'},
+ thumb => {-label => 'Convert options', -multiple => 1},
);
my ($find) = map {{id => $_}} $fields{id} || $Request || ();
elsif ($ENV{REQUEST_METHOD} eq 'POST') {{
my $replace = $row;
$row = {%post{keys %wordcol}};
+ $row->{$_} = [grep {length} @{ $post{"\@$_"} }] for grep {
+ ref $wordcol{$_} eq 'HASH' and $wordcol{$_}->{-multiple}
+ } keys %wordcol;
$_ = length ? $_ : undef for values %{$row};
if (!$row->{form}) {
my $title = $row->{id} ? "entry <small>#$row->{id}</small>" : 'new entry';
package Shiar_Sheet::FormRow {
+ use PLP::Functions 'EscapeHTML';
+
sub input {
my ($row, $col, $attr) = @_;
my $val = $row->{$col} // '';
- $val = '{'.join(',', map {s/,/\\,/gr} @{$val}).'}' if ref $val eq 'ARRAY';
my $html = '';
$html .= qq( $_="$attr->{$_}") for sort grep {!/^-/} keys %{$attr // {}};
(map {
sprintf('<label for="%s">%s</label>', $col, $_)
} $attr->{-label} // ()),
+ (map {
+ sprintf('<input name="%s" value="%s" />', $col, EscapeHTML($_))
+ } ref $val eq 'ARRAY' ? @{$val} : ()),
sprintf('<input id="%s" name="%1$s" value="%s"%s />',
- $col, PLP::Functions::EscapeHTML($val), $html
+ $col, ref $val eq 'ARRAY' ? '' : EscapeHTML($val), $html
),
(map {
sprintf '<img id="%spreview" src="/%s" alt="%s"%s />',