Message Boards Message Boards

0
|
7750 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

FormObject in a Notebook?

Posted 10 years ago

How does one create a form in a notebook, or as a side window, and then retrieve the information after a user has filled it out?

I've been studying the Help for FormObject and every single example has programmatic entry of the data into the FormObject and not a single example of how a user might fill and submit the form. I assume there is some other construction that FormObject goes into but I don't know what it is and I can't find any information on it. For example, how would one turn the following into a desktop (not cloud) object and get the information back out?

form = FormObject["x" -> "Integer"]
2 Replies

Thanks Jason, but I don't want to use CloudDeploy. I want to see if this functionality can be used within a notebook. I've made some progress since my initial posting. Here is the example extended.

The following sets up a FormObject, which might be a more elaborate structure as shown in FormObject Help, and then creates a FormFunction.

formObject = FormObject["x" -> "Integer"];
form = FormFunction[formObject];

Then the following generates the dynamic form, including Submit and Cancel buttons, and returns the result as an Association. Here I typed 5 into the form and pressed Submit.

filledData = form[]
<|"x" -> 5|>

One can then extract the value as:

filledData["x"]
5

Or, with multiple keys, one can Map filledData onto the List of keys.

It would be nice to know if this method, without using CloudDeploy, requires a connection to a Wolfram server.

It may help to look at the Advanced Web Form Creation documentation:

https://reference.wolfram.com/language/tutorial/AdvancedWebFormCreation.html

My impression has been that FormFunction was built to be used with CloudDeploy and that page goes through a bit of how you can use it.

POSTED BY: Jason Grigsby
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract