X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FPresenter%2FTag.pm;h=9ead2f24a371e07eb507982d2541e407af655830;hb=61cdba5d566357f3beabe0e7f3f0cb2d7bdccd73;hp=e65ca7722ef27abed26c402f62f22e58d6d2a242;hpb=081e2bbcae187497b961a1d19d856c8da6e6204b;p=kivitendo-erp.git diff --git a/SL/Presenter/Tag.pm b/SL/Presenter/Tag.pm index e65ca7722..9ead2f24a 100644 --- a/SL/Presenter/Tag.pm +++ b/SL/Presenter/Tag.pm @@ -45,7 +45,7 @@ sub html_tag { sub input_tag { my ($self, $name, $value, %attributes) = @_; - $attributes{id} ||= $self->name_to_id($name); + _set_id_attribute(\%attributes, $name); $attributes{type} ||= 'text'; return $self->html_tag('input', undef, %attributes, name => $name, value => $value); @@ -77,7 +77,7 @@ sub name_to_id { sub select_tag { my ($self, $name, $collection, %attributes) = @_; - $attributes{id} ||= $self->name_to_id($name); + _set_id_attribute(\%attributes, $name); my $value_key = delete($attributes{value_key}) || 'id'; my $title_key = delete($attributes{title_key}) || $value_key; @@ -173,6 +173,14 @@ sub select_tag { return $self->html_tag('select', $code, %attributes, name => $name); } +sub _set_id_attribute { + my ($attributes, $name) = @_; + + $attributes->{id} = name_to_id(undef, $name) if !delete($attributes->{no_id}) && !$attributes->{id}; + + return %{ $attributes }; +} + 1; __END__ @@ -205,6 +213,10 @@ Usage from a template: A module modeled a bit after Rails' ActionView helpers. Several small functions that create HTML tags from various kinds of data sources. +The C attribute is usually calculated automatically. This can be +overridden by either specifying an C attribute or by setting +C to trueish. + =head1 FUNCTIONS =head2 LOW-LEVEL FUNCTIONS