Forums

Populate repeater values from database

gizmochou 2d ago

I have a booking form that uses repeaters containing some text and dropdown fields that allow adding additional people to a booking. The form is working for a new submission and the repeater field values are correctly stored per additional / per row in a database.

However I can not seem to populate the repeater fields when using an amendment link. I can read the values from the database correctly and have tried various methods to set the repeater array fields with no success.

So for example: if a repeater with a design label "Test Repeater 1" and an element name "test_repeater_1" with Start Count 0 and Max count 10 contains two fields   Text Field Name:  "full_name_1[n]" and a dropdown field Name "guest_selection_1[n] containing     (  =Select, yes=YES,  no=NO )  

How do I set the data after reading the values from the database to populate the repeater fields ?

Max_admin 1d ago

Hi gizmochou

The Read Data should be before the Repeater and the form data array should have an array of values matching the repeater entries you want to be loaded, you will also need to set the repeater counter for the repeater area

To understand this better, enable the form debug and submit the form page with the repeater, now check the form Data array, you need to recreate the same data format in order to load the repeater

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gizmochou 17h ago

Hi Max,

This is what I have been doing, and the various sets of repeater fields on a populate load action are displayed (depending on how many were populated on submission). See debug data below ?    The data is being set, the repeater fields are being displayed but not populating with the test data ?

1)  The data array on submission is like this:-  

Array
(
    [view] => form
    [032c2e6857787c295b962a9dc81b0eba] => 39e3fe2a352cdddd82c4c45906084e88
    [7d41636dffe373bc4162624bb40eb72a] => 11ffa33c75ed2bfa3c644b002dca35a8
    [chronoform] => submit-repeater-test-form
    [booker_name] => Primary Booker
    [selection] => 1
    [full_name_1] => Array
        (
            [1] => Guest One
            [2] => Guest Two
        )

    [guest_dropdown_1] => Array
        (
            [1] => one
            [2] => two
        )

    [test_repeater_1] => Array
        (
            [1] => 1
            [2] => 1
        )

    [submit] => 
    [chronopage] => page1
    [sectoken] => 681c7100bcb974.02502402
)VarsArray
(
    [app_active_page] => 1
    [test_repeater_1_key] => NULL
    [selection] => Array
        (
            [selection] => Yes
        )

    [guest_dropdown_1] => Array
        (
            [selection] => Array
                (
                    [0] => ONE
                    [1] => TWO
                )

        )2) On a populate load with preset values the data array is like this:-Array
(
    [view] => form
    [032c2e6857787c295b962a9dc81b0eba] => 39e3fe2a352cdddd82c4c45906084e88
    [7d41636dffe373bc4162624bb40eb72a] => 11ffa33c75ed2bfa3c644b002dca35a8
    [chronoform] => populate-repeater-test-form
    [booker_name] => Test Booker
    [selection] => 1
    [full_name_1] => Array
        (
            [1] => Alice Smith
            [2] => Bob Johnson
            [3] => Charlie Brown
        )

    [guest_dropdown_1] => Array
        (
            [1] => one
            [2] => two
            [3] => three
        )

    [test_repeater_1] => Array
        (
            [1] => 1
            [2] => 2
            [3] => 3
        )

) Vars Array
(
    [app_active_page] => 1
    [php5] => NULL
    [test_repeater_1_key] => NULL
    [Test Data] => NULL
)

You need to login to be able to post a reply.