3
$\begingroup$

FormFunctions work well in a notebook cell.

ff = FormFunction[{{"Count" -> "Number"}, {"Stuff" -> "String"}}, Identity];
ff[]

Mathematica graphics

The following displays the FormFunction in the notebook and then the dialog with the result of the function.

DialogInput[ff[]]

How are they used in DialogInput? I would like to create a dialog with the function and have it return the results of the function to the notebook.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

For a single page:

DialogInput[{x}
, FormControl[
    Dynamic[x, DialogReturn]
  , FormObject[{"Count" -> "Number", "Stuff" -> "String"}]
  ]
]

for a multipage, this is a very simple example but if it works for you we can try to generalize it:

Association[
  DialogInput[{x},
    FormControl[
     Dynamic[x, DialogReturn],
     FormObject[##]
     ]
    ] & @@@ {{"Count" -> "Number", 
    AppearanceRules -> <|"SubmitLabel" -> "Next"|>}, {"Stuff" -> 
     "String"}}
 ]

So there is a limit to crazyness due to the fact that DialogInput is blocking the kernel but we can launch separate dialogs for each page.

$\endgroup$
5
  • $\begingroup$ Interesting solution but it does not include one of the key features of multi-page forms. That being the ability to pass-through the collection of previous selected values from all prior pages to the current page. For example FormFunction[{{"Stuff" -> "String"}, {"PreSelected" -> <|"Input" -> #["Stuff"]|>} &}] $\endgroup$
    – Edmund
    Mar 5, 2018 at 14:04
  • $\begingroup$ @Edmund I see, we can work it out I think, it is just a matter of the flow. E.g. instead of @@@ you can Fold dialog over pages specs so it can access previous answers. Or to keep currentState in an outer module and have it accessible for each inputDialog. $\endgroup$
    – Kuba
    Mar 5, 2018 at 14:13
  • $\begingroup$ @Edmund I don't have time for it now but if you add a full example you'd like to be supported I will try to edit the answer sometime in near future, assuming you are fine with repeated dialog. $\endgroup$
    – Kuba
    Mar 5, 2018 at 14:14
  • $\begingroup$ An actual example can be found here Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/fh9zf.png"] I sent this to WRI support but they have not provided any workarounds as yet. $\endgroup$
    – Edmund
    Mar 6, 2018 at 15:14
  • $\begingroup$ Is there a way to get it to show using DialogNotebook instead of DialogInput? I tried the obvious but it still places the form in the evaluation notebook. $\endgroup$
    – Edmund
    Mar 6, 2018 at 15:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.