2
$\begingroup$

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]

Mathematica graphics

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.

Mathematica graphics

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.

Mathematica graphics

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"]
$\endgroup$
  • $\begingroup$ See FormControl. It’s new in 11 and looks like it’ll handle this case. $\endgroup$ – b3m2a1 Jan 12 '18 at 16:26
  • $\begingroup$ @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. $\endgroup$ – Edmund Jan 12 '18 at 17:36
  • $\begingroup$ @Edmund do you want to deploy it at the end? $\endgroup$ – Kuba Jan 15 '18 at 13:18
  • $\begingroup$ @Kuba Yes, it will be deployed. $\endgroup$ – Edmund Jan 15 '18 at 13:28
  • $\begingroup$ @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. $\endgroup$ – Kuba Jan 15 '18 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.