Buy Now
Sign in

Explanation of CF7 Repeater

rotocal , August 30 2020, 20:01
rotocal 48
August 30 2020, 20:01 #393740
Would you please explain in detail how to create a repeater in CF7 (several fields repeater - including a drop down list with dynamic connection). Thank you
rotocal 48
September 16 2020, 20:10 #393895
Dear sirs I need an aswer to this post. Off course I am interested in acquiring a CF7 license. No matter if I have one for CF6. But I am not going to spend money if you don't have a good manual of CF7. I can help, but at least give me a quick explanation of repeater which is my main issue in CF6. Remember please that not all the people is super expert in everything (Javascript or PHP). The repeater is fundamental for me, since I need to work with lines of requisitions and lines of purchase orders.
The repeater I work with needs to have one dynamic dropdown field which will accept not only descriptions from the list (dymamic data from Dbase), but also free text entered by user. All lines produced need to be saved and retrieved for editing.
Currently I have very complicated issues retrieving the data for the repeater with CF6. All fields are loaded OK in the form, except the dropdown field ...and I need to apply javascript tricks to put the right description in the dropdown field.
On top of this, when one line is deleted I have numbering problems and it is possible that the form shows me two lines with the same number which I need to handle by saving later.Req_form_sample.png
(58.6 KiB)
524 Downloads/Views
(58.6 KiB)
676 Downloads/Views
admin 33
September 16 2020, 20:43 #393898
basically you need a Repeater area, if you want to be able to clone items then enable the cloner in the advanced settings.
For buttons, use the "Cloner" in the button advanced settings to configure the button function
For the fields inside the repeater, use, where Contact is the model name of the data source provided to the repeater, if there is no data source (empty) then use the repeater area name (you get it by hover over the view name)
sem 90
October 21 2020, 08:16 #394435
Simple explanation - thanks Max.
Taking it further, I have a repeater area, a multi field (3 inputs, 1 text, two dropdown) and a clone action to add new rows as required. No database source is used. Clone works (as you specified) but each row has the same field names for the inputs. I need them to be unique. Example field is resource_type_r3. Obviously, the cloned fields can't all have the same field name.
Have tried removing all fields in the multi field, adding a single text field, label Resource and the "auto generate field name based on label selected", reloaded the form, added a second row, entered data in both inputs and only the second row value is stored and sent on the email.
What am I missing?
Also, if I want to format the email into a more usable table for my use, {data:field_name} works perfectly. In the event of using a repeater as above, how would one then include the fields from the extra rows in the email without having to resort to the full data log dump? Alternatively, can the {email_content} output be styled in anyway? Edit - email.output.php solves the customising of the auto email.
sem 90
October 23 2020, 07:04 #394468
Hi. Sorry, anyone got an idea what I'm doing wrong?
As put, the fields in the repeater are normal user input fields - text and dropdown. I just need the user to be able to dynamically add another row of fields if required. I set the min number of repeats to 1, max to 6. And going by Max's explanation above, the text field (for example) within the loop is named area_repeater_73.resource
Here's what I'd like to achieve - the adding of rows and cloning the fields works fine.Screenshot_2020-10-23_at_11.22.24.png
Thanks, mark
admin 33
October 23 2020, 15:00 #394481
Hi mark,
use this syntax to get the current clone id:
For the email content styling, hacking the file you mentioned is not a good solution because it will be overwritten if you update, what kind of styling do you need ?
sem 90
October 23 2020, 15:59 #394489
Thanks Max - sorry, use the syntax where? I'm really impressed with CF7 - it's powerful without messing around with any php - I was just hoping based on what I'd read here that adding the repeater, button and clone action, CF7 would take care of the rest
I was thinking of creating an email template and populating it with the data from the form (like in the old CF days) - but I've grown fond of the Data log view - it's simple and clear so my only mod is below:
<td width="250" valign="middle" align="left" style="background-color:#3a79b8; border:3px solid #3a79b8;">
<span class="chronolabel-sem" style="font-family: helvetica, sans-serif; color: white;">'.$label.'</span>
<td width="450" valign="middle" align="left"><span style="font-family: helvetica, sans-serif;">'
.$this->Parser->displayValue($eunit, $this->Parser->parsev($eunit['uid'], 'email_content', $dataname), 'email')
Altering the table width, changing the colour of the FieldName and I added a dummy class to that column - reason being, we use Outlook primarily - the table renders ok (Outlook still spoils the styling). The manager receives the email and checks the form. They then forward it to out Helpdesk mailbox. The problem is when outlook forwards it, it adds MsoNormal styling to the form - so fonts become sans and the colours are gone - to get around it, I set the helpdesk to render the chronolabel-sem class with the right styling. Then everything looks good. So, I'd not really need to do anything except reapply the modification when upgrading.
sem 90
October 24 2020, 07:55 #394497
Hey Max, just thought. In views mode, for the repeater area there’s a loop with no config options and body with the Multi form elements. Does that mean I need to add a separate loop in actions view and configure that?
admin 33
October 26 2020, 04:49 #394521
The #repeater_area_name should be used anywhere you want to add the current clone number, usually in the field name:
that would be a typical field name inside a repeater
For the email template, I will need to add some setting to style that, the new update will overwrite your changes of course.
I do not understand your question about the loop, the repeater area has a loop already!
sem 90
October 26 2020, 07:08 #394522
Hey Max. My question about the loop - please forget it. I was getting confused and wondered if I needed something else to get it working.
So in my case as example, the field name would be Model.#repeater_area_73.level. As I'm not using external data, Model is the name of the repeater area so I set field name to
Note in your example, it says repeater_area_xx - but in the form, the name of the repeater area is automatically set to area_repeater_xx
This didn't work. No data was captured from either the initial or cloned row. This is part of a multi field. I've attached a copy with just the rows bit. Any help would be fantastic.
sem 90
January 06 2021, 10:08 #395579
Apologies to anyone interested - Max had emailed me with the method and exact syntax to use repeater areas with multi fields in Chronoforms 7 - attached is his demo and below is the text he sent accompanying it. I meant to add this to the post ages ago but forgot.
[Quote Max]
I'm attaching a repeater demo, please try it out, pay attention to the Repeater area name which is "Contact", it's used in the repeater fields names and labels later!
Let me know if you have questions!
Hope it helps people.
(4.64 KiB)
215 Downloads/Views
rotocal 48
February 03 2021, 18:38 #395834
Max good afternoon. I have the repeater working well by creating a new requisition in CF7 (Requisitions have usually header and .. requisition lines) . Repeater is for the lines of course. So I can save the requisition including lines, without any problem. By reading the req (for edition) I have the problem. PHP array has been created and tested for reading the data form the database however I can not populate the requisition lines in the form for editing. Tried with the "Read Data" and also with </> PHP code options
Direct with php code ...
  • =
  • ; // array data model is DataLn

    $sql = "SELECT * FROM dbo_Req_Lines WHERE Req_Id='" . trim($Req_Id) . "' ORDER BY Linea ASC;";
    if ($result = mysqli_query($con, $sql)) {
    // Pass information to form ....
    $cur_count = 1;
    while ($row = mysqli_fetch_assoc($result)) {
    $linea_ac = $row['Linea'];
    $this->data['DataLn'][$cur_count]['ln'] = $linea_ac;
    $this->data['DataLn'][$cur_count]['lnh'] = $linea_ac;
    $this->data['DataLn'][$cur_count]['item'] = $row['Item'];
    $this->data['DataLn'][$cur_count]['descripcion'] = trim($row['Descripcion']);
    $this->data['DataLn'][$cur_count]['ref_pn'] = $row['NoParte'];
    $this->data['DataLn'][$cur_count]['cant'] = $row['Cantidad'];
    $this->data['DataLn'][$cur_count]['udm'] = $row['Udm'];
    $this->data['DataLn'][$cur_count]['precio_unit'] = $row['PrecioUnit'];
    $this->data['DataLn'][$cur_count]['iva'] = $row['IvaLinea'] * 100;
    $this->data['DataLn'][$cur_count]['observaciones'] = $row['Observaciones'];
    echo "Counter: " . $cur_count . " - ln : ". trim($row['Linea']) . " - lnh : " . trim($this->data['DataLn'][$cur_count]['lnh']) . " - Descr : " . trim($this->data['DataLn'][$cur_count]['descripcion']) . " - Cant : " . trim($this->data['DataLn'][$cur_count]['cant']) . "<br>";
    $cur_count = $cur_count + 1;
    $this->data['cant_lineas_leidas'] = $cur_count; // review later attention event will be used- js event
    } else {
    echo "Error: " . $sql . "<br>" . mysqli_error($con);

    echo "<br>";
    print_r($this->data['DataLn']); // Here the array is printed and is correct
    Question: If the data is already in the array DataLn,.. what is missing in order to see the lines in the repeater??
    Repeater is inside a container .... and inside the repeater the fields are contained in a Multifield field area.
    Repeater name is = Reqlines
    What should by the settings on the repeater to read a bunch of lines from a database table... would you explain in detail ?
    Thank you
    rotocal 48
    April 30 2021, 01:26 #396328
    My problem is not by creating repeater lines and saving them. It is when I retrieve the lines for editing and / or add lines. Anyone knows how to populate the repeater lines after reading these lines from a data base with php? Thank you