From: Sven Schöling Date: Mon, 27 May 2013 15:40:23 +0000 (+0200) Subject: Presenter: Array Tags mit eindeutigen IDs rendern X-Git-Tag: release-3.1.0beta1~401^2~10 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=10ca9778ea95bb53b0f8a8988bb0f1ed130823de;p=kivitendo-erp.git Presenter: Array Tags mit eindeutigen IDs rendern Sonst funktionieren zum Beispiel Checkbox/Label Zuordnung oder Seriendatumsfelder nicht. --- 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;