Revision 10ca9778
Von Sven Schöling vor mehr als 11 Jahren hinzugefügt
SL/Presenter/Tag.pm | ||
---|---|---|
19 | 19 |
return $object->$method(@params); |
20 | 20 |
} |
21 | 21 |
|
22 |
{ # This will give you an id for identifying html tags and such. |
|
23 |
# It's guaranteed to be unique unless you exceed 10 mio calls per request. |
|
24 |
# Do not use these id's to store information across requests. |
|
25 |
my $_id_sequence = int rand 1e7; |
|
26 |
sub _id { |
|
27 |
return ( $_id_sequence = ($_id_sequence + 1) % 1e7 ); |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
22 | 31 |
|
23 | 32 |
sub stringify_attributes { |
24 | 33 |
my ($self, %params) = @_; |
... | ... | |
68 | 77 |
sub name_to_id { |
69 | 78 |
my ($self, $name) = @_; |
70 | 79 |
|
80 |
$name =~ s/\[\+?\]/ _id() /ge; # give constructs with [] or [+] unique ids |
|
71 | 81 |
$name =~ s/[^\w_]/_/g; |
72 | 82 |
$name =~ s/_+/_/g; |
73 | 83 |
|
Auch abrufbar als: Unified diff
Presenter: Array Tags mit eindeutigen IDs rendern
Sonst funktionieren zum Beispiel Checkbox/Label Zuordnung oder
Seriendatumsfelder nicht.