Buy Now
Sign in

Load values into fields in a repeater area

rtobias , March 02 2018, 20:11
R
rtobias 53
March 02 2018, 20:11 #375812
Hi. I'm trying to figure out how to load data dynamically into a repeater area. I'm loading JSON data from a curl request that I want in input fields so someone can update values and save them again.
I have the keys working where my labels for First Name will be "billingAddress First Name" and "shippingAddress First Name" by using "{var:area_repeater5.key} First Name". Normally, to load values I would probably use {vars:getBillingAddressFirstName} or {data:addresses.billingAddress.FirstName}, but I don't know if there is a way to {var:area_repeater5.key} inside of my {data:} reference. Addresses are my simple case where there are only two, but another part of the json could contain an array of 1-100 sets of data (usually less than 20).
I have the following already:
    [getAddresses] => Array
(
[returned] => Array
(
[billingAddress] => Array
(
[FirstName] => MyFirstName
[LastName] => MyLastName
[Address1] => 555 Somewhere Drive
[Address2] =>
[city] => Somewhere
[CompanyName] => My Company 02
[PhoneNumber] => (555) 555-5555
[postalCode] => 55555
[state] => PA
[country] => US
)

[shippingAddress] => Array
(
[FirstName] => MyFirstName
[LastName] => MyLastName
[Address1] => 555 Somewhere Way
[Address2] =>
[city] => Somewhere
[CompanyName] => My Company 02
[PhoneNumber] => (555) 555-5555
[postalCode] => 55555
[state] => PA
[country] => US
)

)

[var] => Array
(
[billingAddress] => Array
(
[FirstName] => Randy
[LastName] => MyL
[Address1] => 555 Somewhere Drive
[Address2] =>
[city] => Here
[CompanyName] => My Company 02
[PhoneNumber] => (555) 555-5555
[postalCode] => 55555
[state] => PA
[country] => US
)

[shippingAddress] => Array
(
[FirstName] => MyFirstName
[LastName] => MyLastName
[Address1] => 555 Somewhere Way
[Address2] =>
[city] => Here
[CompanyName] => My Company 02
[PhoneNumber] => (555) 555-5555
[postalCode] => 55555
[state] => PA
[country] => US
)

)

)

[getAddressesKeys] => Array
(
[returned] => Array
(
[0] => billingAddress
[1] => shippingAddress
)

[var] => Array
(
[0] => billingAddress
[1] => shippingAddress
)

)
Randy
admin 27
March 03 2018, 03:55 #375817
Hi Randy,
You can use a PHP function before the "Display section" to alter the data received by curl and set it into a new variale which you can use as the data provider for the repeater.
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
R
rtobias 53
March 08 2018, 19:53 #375969
Hi Max,
I have all of the data already. Where I am kind of stuck is even if I have the data provider of the repeater area set to {data:addresses}, I don't know how to get the values in the text fields. I have just updated to make sure that I'm on the latest version.
My setup is:
[Page1]
|-->text field (variable used with curl to get values
[Page2]
|--fieldset area
|--> repeater area
|--> text field
For my actions, basically on my first page submit, I get make my curl request and process the response. I do multipage actions everywhere and I use the addresses on the second page, so I have it before that display action.
I actually have almost exclusively been using php because not sure how to use the curl action properly.
Randy