Repeated Group -> Headline with consecutive numeration

Hi,

i'm a little stuck with the following problem:

I have a form with some groups. One of this groups could be repeated 3 times. I have to make the headlines in the following way:

  • "Repeated headline 1"
    • field 1
    • field 2
    • field 3
  • "Repeated headline 2"
    • field 1
    • field 2
    • field 3
  • "Repeated headline 3"
    • field 1
    • field 2
    • field 3
The red number is, what i need. When you normally repeat a group, you have always the same headline. I'm searching for a way with consecutive numbering.


Thx for help,
Dan :)
 
I would do it with a custom template:
copy e.g. the default template, edit default.php, around line 94 change
Code:
<?php if ($group->canRepeat) {
foreach ($group->subgroups as $subgroup) {
  ?>
to something like
Code:
<?php if ($group->canRepeat) {
$i=0;
  foreach ($group->subgroups as $subgroup) {
$i=i+1;
echo 'your header text '.$i;
?>
 
Hi troester,

i'm sorry, but it doesn't work :-/. have a look at the attached screenshot for more details.
 

Attachments

  • screenshot.jpg
    screenshot.jpg
    345.5 KB · Views: 216
Ok, a typo; it must be
$i=$i+1;
echo '<span style="color:red">Teilanlage '.$i.'</span>';

Change your group name to "Angaben zur Anlage" and add the style you want
Then you'll get somethink like
Angaben zur Anlage
Teilanlage 1
xxx
xxx
+ -

Teilanlage 2
...
 
still not working. This is my code:

PHP:
<?php if ($group->canRepeat) {    
     $i=0;
     foreach ($group->subgroups as $subgroup) {
         $i=$i+1;
?>
<div class="fabrikSubGroup">
    <?php echo 'Teilanlage '.$i; ?>

Now it shows the subheadline on every repeated subgroup, but the counter doesn't work:

  • Teilanlage 1
  • Teilanlage 1
  • Teilanlage 1
Maybe it's only possible with JS? Because it's generated on the client side.
 
It's working on my site with exactly your code.


Edit: ah, I only tested with existing subgroups. Adding a subgroup is JS, so yes, there must be some JS to do this (but I don't know where).
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top