X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FTag.pm;h=25c7d0c2cb16e84b04741e9913fa441e910fea37;hb=90f0e0b497ad75866cb8d15dd1a593f31ffbc6f7;hp=c4b9b7f784535ca9c735de51415897f548def9f1;hpb=383871e4d212a5285c17b22ca87ae5f9340dca96;p=kivitendo-erp.git diff --git a/SL/Presenter/Tag.pm b/SL/Presenter/Tag.pm index c4b9b7f78..25c7d0c2c 100644 --- a/SL/Presenter/Tag.pm +++ b/SL/Presenter/Tag.pm @@ -46,6 +46,15 @@ sub _J { return $string; } +sub join_values { + my ($name, $value) = @_; + my $spacer = $name eq 'class' ? ' ' : ''; # join classes with spaces, everything else as is + + ref $value && 'ARRAY' eq ref $value + ? join $spacer, map { join_values($name, $_) } @$value + : $value +} + sub stringify_attributes { my (%params) = @_; @@ -54,6 +63,7 @@ sub stringify_attributes { next unless $name; next if $_valueless_attributes{$name} && !$value; $value = '' if !defined($value); + $value = join_values($name, $value) if ref $value && 'ARRAY' eq ref $value; push @result, $_valueless_attributes{$name} ? escape($name) : escape($name) . '="' . escape($value) . '"'; } @@ -237,6 +247,9 @@ sub select_tag { sub checkbox_tag { my ($name, %attributes) = @_; + my %label_attributes = map { (substr($_, 6) => $attributes{$_}) } grep { m{^label_} } keys %attributes; + delete @attributes{grep { m{^label_} } keys %attributes}; + _set_id_attribute(\%attributes, $name); $attributes{value} = 1 unless defined $attributes{value}; @@ -253,7 +266,7 @@ sub checkbox_tag { my $code = ''; $code .= hidden_tag($name, 0, %attributes, id => $attributes{id} . '_hidden') if $for_submit; $code .= html_tag('input', undef, %attributes, name => $name, type => 'checkbox'); - $code .= html_tag('label', $label, for => $attributes{id}) if $label; + $code .= html_tag('label', $label, for => $attributes{id}, %label_attributes) if $label; $code .= javascript(qq|\$('#$attributes{id}').checkall('$checkall');|) if $checkall; return $code; @@ -262,6 +275,9 @@ sub checkbox_tag { sub radio_button_tag { my ($name, %attributes) = @_; + my %label_attributes = map { (substr($_, 6) => $attributes{$_}) } grep { m{^label_} } keys %attributes; + delete @attributes{grep { m{^label_} } keys %attributes}; + $attributes{value} = 1 unless exists $attributes{value}; _set_id_attribute(\%attributes, $name, 1); @@ -276,7 +292,7 @@ sub radio_button_tag { } my $code = html_tag('input', undef, %attributes, name => $name, type => 'radio'); - $code .= html_tag('label', $label, for => $attributes{id}) if $label; + $code .= html_tag('label', $label, for => $attributes{id}, %label_attributes) if $label; return $code; } @@ -564,7 +580,10 @@ C. The tag's C defaults to C<1>. If C<%attributes> contains a key C