5
$\begingroup$

I have been looking at the FormObject and FormFunction. Can FormObject and FormFunction be used without CloudDeploy?

Are there any examples of using FormObject or FormFunction that show how a submit would be done for a given FormObject?

Should submit be implemented as a Button control?

$\endgroup$
  • $\begingroup$ I.m.o. FormFunction is designed for cloud deployment. Even form[] is meant only for a quick check/preview. To have full control just use DialogInput/Input and friends. $\endgroup$ – Kuba Feb 24 '17 at 8:58
9
$\begingroup$

This is a form definition:

ff = FormFunction[FormObject[<|"x" -> "Number"|>], #x^2 &]

Now watch the [] after the ff, this launches the form and waits for input and shows a submit button

ff[]

If you want put a value in the form without showing a submit button:

ff["x" -> 9]

Does this answer your question?

$\endgroup$
  • $\begingroup$ pvanbijen - Thank you very much! This is very useful ! $\endgroup$ – Doug Kimzey May 6 '15 at 10:47
1
$\begingroup$

I have found that Wolfram Language Documentation has only one example on how to read data from inside a notebook using a FormFunction and it is not easy for a newcomer to notice or understand how input is read and what is the form of output.

For the example above, it is not necessary to use FormObject as the first argument of FormFunction and you don't even have to pass a Function as the second argument. A single argument with a list of rules representing fields and types is sufficient. Therefore you can :

  1. Construct the form

    twofields = FormFunction[{"x" -> "Number"},{"y"->"String"}];
    
  2. Complete the form

    twofields[]
    

enter image description here

    Output= <|"x" -> 3, "y" -> "three"|> 
$\endgroup$
  • $\begingroup$ Am I really the only one who has print to console settings and form[] displays in MassagesNotebook? $\endgroup$ – Kuba Feb 24 '17 at 8:57
  • $\begingroup$ Can anybody tell me how to tweak the appearance of field boxes, e.g. width and height, font size, that will be great. $\endgroup$ – Athanassios Feb 24 '17 at 8:57

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.