# How to refresh a TemplateSlot in a dynamic FormFunction?

I am building a FormFunction that makes use of a TemplateSlot to define a field. This minimal example demonstrates the issue.

FormFunction[
{
"state" -> "USState",
"county" -> TemplateSlot["state"]["Subdivisions"]
}, Identity]


This works as expected with the "county" field being created with the "state"'s counties once the state is entered and Tab key is pressed.

However, if I change the state and select Tab again the counties do not refresh to the new state. It just highlights the text of the new state.

How can the TemplateSlot be refreshed when its dependent field is updated?

I tried wrapping TemplateSlot in Dynamic without success.

FormFunction[
{
"state" -> "USState",
"county" -> Dynamic[TemplateSlot["state"]["Subdivisions"]]
}, Identity]


The UI will be used on the desktop but I prefer a solution that will work when deployed to the cloud. Also I want to stick with the Creating Form Interfaces & Apps guide's form approach instead of the Custom Interface Construction approach.

Notebook with all issues demonstrated as requested.

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/IGPpQ.png"]

• See FormControl. It’s new in 11 and looks like it’ll handle this case. – b3m2a1 Jan 12 '18 at 16:26
• @b3m2a1 That does not quite work. Even is you set "AutoSubmitting"->True on the field the value is "state" gets over written with the InputForm of the entity. This messes up the display and the value. – Edmund Jan 12 '18 at 17:36
• @Edmund do you want to deploy it at the end? – Kuba Jan 15 '18 at 13:18
• @Kuba Yes, it will be deployed. – Edmund Jan 15 '18 at 13:28
• @Edmund I'm 90% sure that all efforts to make desktop's form behave well will be useless in cloud. Worth to mention what is the final goal. p.s. I was playing with 'dynamic' form functions once, but the conclusion was that they are 'dynamic only once' :) which is pretty limited. I'm afraid that custom html/js or a CloudCDF solution is the only flexible answer. – Kuba Jan 15 '18 at 13:36