From 10ca9778ea95bb53b0f8a8988bb0f1ed130823de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 27 May 2013 17:40:23 +0200 Subject: [PATCH] Presenter: Array Tags mit eindeutigen IDs rendern Sonst funktionieren zum Beispiel Checkbox/Label Zuordnung oder Seriendatumsfelder nicht. --- SL/Presenter/Tag.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SL/Presenter/Tag.pm b/SL/Presenter/Tag.pm index 9ead2f24a..e5690e79d 100644 --- a/SL/Presenter/Tag.pm +++ b/SL/Presenter/Tag.pm @@ -19,6 +19,15 @@ sub _call_on { return $object->$method(@params); } +{ # This will give you an id for identifying html tags and such. + # It's guaranteed to be unique unless you exceed 10 mio calls per request. + # Do not use these id's to store information across requests. +my $_id_sequence = int rand 1e7; +sub _id { + return ( $_id_sequence = ($_id_sequence + 1) % 1e7 ); +} +} + sub stringify_attributes { my ($self, %params) = @_; @@ -68,6 +77,7 @@ sub man_days_tag { sub name_to_id { my ($self, $name) = @_; + $name =~ s/\[\+?\]/ _id() /ge; # give constructs with [] or [+] unique ids $name =~ s/[^\w_]/_/g; $name =~ s/_+/_/g; -- 2.20.1