From 50cd4bdaf6e14b7e424b0240bb27f921ce34b8ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 5 Aug 2014 12:52:49 +0200 Subject: [PATCH] L.radio_button_tag: id erhalten wenn sie schon vorher gesetzt ist. --- SL/Presenter/Tag.pm | 7 +++++-- SL/Template/Plugin/L.pm | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/SL/Presenter/Tag.pm b/SL/Presenter/Tag.pm index bd489066b..552df34aa 100644 --- a/SL/Presenter/Tag.pm +++ b/SL/Presenter/Tag.pm @@ -190,9 +190,12 @@ sub select_tag { } sub _set_id_attribute { - my ($attributes, $name) = @_; + my ($attributes, $name, $unique) = @_; - $attributes->{id} = name_to_id(undef, $name) if !delete($attributes->{no_id}) && !$attributes->{id}; + if (!delete($attributes->{no_id}) && !$attributes->{id}) { + $attributes->{id} = name_to_id(undef, $name); + $attributes->{id} .= '_' . $attributes->{value} if $unique; + } return %{ $attributes }; } diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index 8cc93a673..88cf4d21e 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -69,8 +69,8 @@ sub simple_format { return _call_presenter('simple_format', @_); } sub part_picker { return _call_presenter('part_picker', @_); } sub _set_id_attribute { - my ($attributes, $name) = @_; - SL::Presenter::Tag::_set_id_attribute($attributes, $name); + my ($attributes, $name, $unique) = @_; + SL::Presenter::Tag::_set_id_attribute($attributes, $name, $unique); } sub img_tag { @@ -119,9 +119,9 @@ sub checkbox_tag { sub radio_button_tag { my ($self, $name, %attributes) = _hashify(2, @_); - _set_id_attribute(\%attributes, $name); $attributes{value} = 1 unless exists $attributes{value}; - $attributes{id} .= '_' . $attributes{value}; + + _set_id_attribute(\%attributes, $name, 1); my $label = delete $attributes{label}; if ($attributes{checked}) { -- 2.20.1