({{, (RefLink[RepeatingElement, paclet:ref/RepeatingElement])[spec] 
represents an arbitrarily repeated type of element in an interpreter, API or form specification.}, {, (RefLink[RepeatingElement, paclet:ref/RepeatingElement])[spec,max]
represents an element that can appear at most max times.}, {, (RefLink[RepeatingElement, paclet:ref/RepeatingElement])[spec,{min,max}]
represents an element that can appear between min and max times.}, {, (RefLink[RepeatingElement, paclet:ref/RepeatingElement])[spec,{n,{min,max}}]
represents an element that initially appears n times in a form.}, {, (RefLink[RepeatingElement, paclet:ref/RepeatingElement])[spec,{{i,n},{min,max}}]
represents an element where i takes successive values.}})

OpenersNotesSection(Spacer1)Details

In the context of (RefLink[Interpreter, paclet:ref/Interpreter]), spec can be any specification used for (RefLink[Interpreter, paclet:ref/Interpreter]), including (RefLink[CompoundElement, paclet:ref/CompoundElement]) or (RefLink[RepeatingElement, paclet:ref/RepeatingElement]).

In the context of (RefLink[FormObject, paclet:ref/FormObject]) and (RefLink[FormFunction, paclet:ref/FormFunction]), spec can be any specification used for forms, including the full association and (RefLink[CompoundElement, paclet:ref/CompoundElement]).

If no minimum repeat is specified, (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) initially represents a single element in a form.

(RefLink[Interpreter, paclet:ref/Interpreter])[RepeatingElement[spec]][input] is effectively equivalent to (RefLink[Interpreter, paclet:ref/Interpreter])[spec][input], since (RefLink[Interpreter, paclet:ref/Interpreter]) automatically lists on input.

(RefLink[RepeatingElement, paclet:ref/RepeatingElement]) can appear nested inside a (RefLink[CompoundElement, paclet:ref/CompoundElement]) specification in the context of (RefLink[Interpreter, paclet:ref/Interpreter]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (13)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

(RefLink[RepeatingElement, paclet:ref/RepeatingElement]) can be used in (RefLink[FormFunction, paclet:ref/FormFunction]) to repeat a field:

FormFunction["field" -> RepeatingElement["String"]][]

(RefLink[RepeatingElement, paclet:ref/RepeatingElement]) fields can also be filled programmatically:

api=APIFunction["field" -> RepeatingElement["City"],f];
api["field" -> {"helsinki", "goteborg"}]

api["field[1]" -> "oslo"]

In an (RefLink[APIFunction, paclet:ref/APIFunction]), (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) specifies that all instances of a particular parameter should be used:

APIFunction[{"x"->RepeatingElement["Integer"]},#x^2&][{"x"->2,"x"->3}]

Without (RefLink[RepeatingElement, paclet:ref/RepeatingElement]), only the last instance is used:

APIFunction[{"x"->"Integer"},#x^2&][{"x"->2,"x"->3}]

(RefLink[Interpreter, paclet:ref/Interpreter]) threads over lists, so (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) is not needed here:

Interpreter[RepeatingElement["Integer"]][{"1", "2", "5"}]

Interpreter["Integer"][{"1", "2", "5"}]

This interprets lists containing a single integer and a repeating list of integers:

Interpreter[CompoundElement[{"Integer",RepeatingElement["Integer"]}]][{"6",{"1","2","3"}}]

(RefLink[RepeatingElement, paclet:ref/RepeatingElement]) can be used to limit the number of elements:

Interpreter[RepeatingElement["Integer",2]][{"1", "7"}]

Interpreter[RepeatingElement["Integer",2]][{"1", "7", "5"}]

OpenersExampleSection1(Spacer1)Scope  (3)

Use the second argument to limit the number of elements:

Interpreter[RepeatingElement["String",2]][{"foo", "bar", "baz"}]

Interpreter[RepeatingElement["String",{3,5}]][{"foo", "bar"}]

Use the second argument to set the initial number of fields to be displayed:

CloudDeploy[FormFunction["field" -> RepeatingElement["String", {2,{1, 5}}]]]

Use the second argument to change the label of the fields:

CloudDeploy[FormFunction["number of occupants" -> RepeatingElement[<|"Interpreter" -> "Integer", "Label" :> "room " <> ToString[i]|>, {{i,2},{1, 5}}]]]

OpenersExampleSection3(Spacer1)Properties & Relations  (4)

Use (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) in conjunction with (RefLink[CompoundElement, paclet:ref/CompoundElement]) to interpret complicated structures:

Interpreter[CompoundElement[<|"numbers" -> RepeatingElement["Integer"], "fruit" -> RepeatingElement[{"apple" -> "pomme", "orange" -> "orange", "grapefruit" -> "pamplemousse"}]|>]][<|"numbers" -> {"1","14", "-4"},"fruit" -> {"apple" , "pomme", "grapefruit"}|>]

Use it in conjunction with (RefLink[Alternatives, paclet:ref/Alternatives]) to interpret data that can have different shapes:

Interpreter[CompoundElement[<|"x" -> RepeatingElement["City"|"Country"]|>]][<|"x" -> {"berlin", "portugal", "tegucigalpa"}|>]

Interpreter[CompoundElement[<|"x" -> RepeatingElement["AmusementPark"]|>]][<|"x" -> {"coliseum"|"disneyland", "six flags"|"central park" }|>]

(RefLink[RepeatingElement, paclet:ref/RepeatingElement]) should not be confused with (RefLink[DelimitedSequence, paclet:ref/DelimitedSequence]). (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) does not permit a single string separated by delimiters:

Interpreter[RepeatingElement["Integer"]]["1,2,3"]

Use (RefLink[DelimitedSequence, paclet:ref/DelimitedSequence]) for elements separated by delimiters:

Interpreter[DelimitedSequence["Integer"]]["1,2,3"]

Use with (RefLink[CompoundElement, paclet:ref/CompoundElement]) in the context of (RefLink[FormFunction, paclet:ref/FormFunction]) to generate a table of fields:

CloudDeploy[FormFunction["names" -> RepeatingElement[CompoundElement[<|"first"-> "String", "last" -> "String"|>]]]]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

When using the second argument of (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) with an index in the context of a web form or an API, the "Interpreter" field cannot depend on the index:

FormObject["x" ->RepeatingElement[<|"Interpreter" :> Range[i], "Label" :> ToString[i]|>,{{i,1},{1,4}}]]

This is due to the fact that the "Interpreter" field cannot be delayed:

FormObject["x" -><|"Interpreter" :> (Print["evaluated"];"String")|>]//InputForm

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CompoundElement, paclet:ref/CompoundElement])  ▪  (RefLink[DelimitedSequence, paclet:ref/DelimitedSequence])  ▪  (RefLink[RectangularRepeatingElement, paclet:ref/RectangularRepeatingElement])  ▪  (RefLink[SquareRepeatingElement, paclet:ref/SquareRepeatingElement])  ▪  (RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[Repeated, paclet:ref/Repeated])  ▪  (RefLink[FormFunction, paclet:ref/FormFunction])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Form Structure & Layout, paclet:guide/FormStructureAndLayout])}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}, {▪(RefLinkPlain[Free-Form & External Input, paclet:guide/FreeFormAndExternalInput])}, {▪(RefLinkPlain[Creating Form Interfaces & Apps, paclet:guide/CreatingFormsAndApps])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/36-creating-websites-and-apps.html])(WebLink[: Creating Websites and Apps, https://www.wolfram.com/language/elementary-introduction/36-creating-websites-and-apps.html])}})}})