word edit: multiinput styling for configured columns
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 13 Jun 2020 11:02:38 +0000 (13:02 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 20 Oct 2020 20:49:11 +0000 (22:49 +0200)
writer.plp

index d7167548f948991bf55aef311fd87ac7f86f7325..3f9ed98bc647c1e7b2a909a6f920c3fdf8568c93 100644 (file)
@@ -31,6 +31,7 @@ form > ul > li > label + * {
        width: 40em;
 }
 
+.multiinput,
 input,select {
        box-sizing: border-box;
        flex-grow: 1;
@@ -305,18 +306,19 @@ package Shiar_Sheet::FormRow {
                        );
                }
                else {
+                       my $multiple = ref $val eq 'ARRAY' || $attr->{-multiple};
                        return (
                                (map {
                                        sprintf('<label for="%s">%s</label>', $col, $_)
                                } $attr->{-label} // ()),
-                               ref $val ne 'ARRAY' ? () : '<span class="inline multiinput">',
+                               $multiple ? '<span class="inline multiinput">' : (),
                                (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, ref $val eq 'ARRAY' ? '' : EscapeHTML($val), $html
+                                       $col, $multiple ? '' : EscapeHTML($val), $html
                                ),
-                               ref $val ne 'ARRAY' ? () : '</span>',
+                               $multiple ? '</span>' : (),
                                (map {
                                        sprintf '<img id="%spreview" src="/%s" alt="%s"%s />',
                                                $col, $_, $row->{form}, $col eq 'source' ? ' hidden' : '';