I am trying to develop a web form wherein the first page asks users how many cities they would like to compare, and the second page dynamically creates that many input boxes. Once the user inputs the full information on the second page, they submit it and a function generates and displays a map for them. To troubleshoot it I've made functionBuildMap[]
just return a generic map:
functionBuildMap := Module[{origin, citylist},
GeoGraphics[Polygon[GeoVariant[Entity["GeographicRegion", "World"], "SimplifiedArea"]]]
]
I've been trying to follow along with the tutorial located at https://reference.wolfram.com/language/tutorial/AdvancedWebFormCreation.html but am getting nowhere besides bashing my head against the wall.
I've tried implementing the multi-page form technique as such:
FormFunction[firstform,
FormFunction[secondaryform[#"Destination city count"],
functionBuildMap[origin, citylist]&]&
]
This technique correctly shows the first form, and after filling out the second form will just return the user to the first form again saying that required fields have not been filled out...
The problem being that while the first form feeds correctly into the second form through the &
operator, after the second form is filled out it loops back to the first form saying that it is missing information.
I then tried to use the dynamic forms technique instead:
CloudDeploy @ FormFunction[
{
"Destination city count" -> "Integer",
"Origin City" -> "Airport",
Table["Destination " <> ToString[i]->"String",{i, TemplateSlot[#"Destination city count"]}]
},
functionBuildMap[origin, citylist]&
]
But this form just errors with
Table: Iterator {i, TemplateSlot[#Destination city count]} does not have appropriate bounds.
Yet while this cannot correctly receive input, it will display a map when the use submits their form on the cloud link provided.
Finally, I've also tried dynamic forms with the &
operator as such:
CloudDeploy @ FormFunction[
{
"Destination city count" -> "Integer",
"Origin City" -> "Airport",
Table["Destination " <> ToString[i]->"String", {i, TemplateSlot[#"Destination city count"]}]& (* notice the "&" here this time around*)
},
functionBuildMap[origin, citylist]&
]
This only leads to a "$Failed" output on my cloud object page. Additionally it shows this error when I run it:
FormFunction: FormFunction expects a rule, a list of rules, an association or a FormObject as first argument.