Forums

Explanation of CF7 Repeater

rotocal 30 Aug, 2020
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 16 Sep, 2020
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.
Max_admin 16 Sep, 2020
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 Contact.#Contact.name, 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)
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sem 21 Oct, 2020
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.

mark
sem 23 Oct, 2020
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.

Thanks, mark
Max_admin 23 Oct, 2020
Hi mark,

use this syntax to get the current clone id:
#repeater_area_name
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 ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sem 23 Oct, 2020
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🙂

Email:

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>
<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')
.'</span></td>


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.

mark
sem 24 Oct, 2020
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?

mark
Max_admin 26 Oct, 2020
The #repeater_area_name should be used anywhere you want to add the current clone number, usually in the field name:
Model.#repeater_area_name.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!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sem 26 Oct, 2020
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

area_repeater_73.#area_repeater_73.level

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.[file=13424]MultiRowTest_26_Oct_2020_08_42_15.cf7bak[/file]

mark
sem 06 Jan, 2021
2 Likes
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!

[/Quote]

​[file=13676]Repeater_Demo_05_Nov_2020_14_15_28.cf7bak[/file]
Hope it helps people.

Mark
rotocal 03 Feb, 2021
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 ...

$this->data['DataLn'] = []; // 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;
}
mysqli_free_result($result);
$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 30 Apr, 2021
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
kollo2 19 Feb, 2022
Answer
Hy,

Add PHP in Read Data Event - > found:
$this->data['repeater_elements'] = array_values(json_decode($this->get("read_data_XX.Model.repeater_elements","default"),true));

In the Repeater Settings set Data Source
{data:repeater_elements}
rotocal 18 Mar, 2022
Regular php section reading the data via mysqli_query +
Populating the array $this->data['DataModel'][counter][repeater_item] +
what kollo2 recommended above as data source for the repeater : {data:[strong]DataModel[/strong]} solved the problem.
Thank you all!
sem 01 Apr, 2022
Hi - repeaters working well - not using a DB though. What I'd like to do is get the repeater data from the form into a tabulated view when inserted into the email. Right now, after only inputting one row {data:SectionC} gives me the following output in the email:


{"1":{"name":"SOmeone","dob":"12\/12\/2012","date_of_admission":"30\/03\/2022","id_number":"0123456789","date_of_onset_of_problem":"","provide_details":"","date_sent_to_lab":"","date_of_last_assessment":""}}


Using {data.pr:SectionC} gives the output in a more human readable form for sure but ideally I'd like to tabulate the result:


(
    [1] => Array
        (
            [name] => Someone
            [dob] => 12/12/2022
            [date_of_admission] => 12/02/2023
            [id_number] => 0123456789
            [date_of_onset_of_problem] => 
            [provide_details] => 
            [date_sent_to_lab] => 
            [date_of_last_risk_assessment] => 
        )
)

I don't mind putting an HTML table in the email and addressing the values manually with a short code per cell (as I'll limit the number of rows anyway) but I can't get the syntax right.

sem
This topic is locked and no more replies can be posted.