FormPage[formspec,func]

represents an active page that takes input from a form and generates results on the same page by applying func to the values obtained from the form whose structure is defined by formspec.

FormPage[{"name1"type1,},func]

represents an active form page with fields named namei interpreted as types typei.

FormPage[{{"name1",label1}type1,},func]

uses labeli as the label for the field named namei.

FormPage[{namespec1type1default1,},func]

uses defaulti as the default for the field specified by namespeci.

FormPage[formspec,func,form]

lays out the page according to the layout specification form.

FormPage[formspec,func,initformresform]

uses initform as the initial layout specification and resform as the layout specification for result pages.

Details and Options

  • CloudDeploy[FormPage[]] yields a cloud object containing an active form page.
  • FormPage[formspec,func][<|"namek"->inputk,|>] inserts the inputs given into the initial form specified by the FormPage object.
  • Setting[FormPage[formspec,func]] evaluates to func applied to the current values of the form.
  • In FormPage[formspec,func,layout], possible specifications for layout include:
  • "ResultBelow"display results below the form
    "ResultAbove"display results above the form
    {elem1,elem2,}display layout elements in the specified order
  • In FormPage[formspec,func,{elem1,elem2,}], possible elemi include:
  • "Form"the form as specified by formspec
    "Result"results generated by applying func
    "Button"button for submitting the form
  • Overall options for FormPage include:
  • AppearanceRules Automaticassociation giving overall appearance rules
    FormLayoutFunction Automaticfunction to generate layout for the form
    FormProtectionMethodAutomaticmethod for spam protection
    PageTheme Automaticoverall theme to use for the form
    ImageFormattingWidth$ImageFormattingWidthwrapping width for output formatting
    ImageSizeAutomaticoverall image size for output

Examples

open allclose all

Basic Examples  (1)

Use FormPage to continuously interact with a webpage:

Scope  (31)

Interpreter Specifications  (6)

Use rich Interpreter specifications:

The Interpreter head is optional, but useful to specify options or other arguments to Interpreter:

A list can be used to create a menu:

An entity list can be used as a menu:

Choices can be any expression:

A list of rules allows for label specification:

Defaults  (3)

Specify a default for a field; fields that have a default are not required:

Fields can be optional without having a default:

Use RuleDelayed to evaluate a new default every time:

Input  (2)

Create a form with input inside:

Input can be delayed:

Label  (1)

Change the label for a field:

You can use RuleDelayed and return any expression:

Use None to remove the label:

Appearance  (4)

Change the default label to be something different from the key:

Labels can be any expression:

Change the appearance of single fields:

Use RuleDelayed to evaluate an expression in the cloud:

Use non-rule elements to change the default appearance:

Controls  (7)

Different types have different controllers. Color pickers for "Color":

Or file pickers for file formats:

Checkboxes for "Boolean":

Change the default controller:

Multiple choices support various types of controllers:

Labels for radio buttons can be anything you want:

The control specification also accepts pure functions:

Disambiguation  (3)

For strings that are interpreted from natural language in the Wolfram Cloud, sometimes results might be ambiguous:

Disambiguation is off for most types by default, but it can be easily activated:

Sometimes several parts of the expression are ambiguous:

Dynamic Forms  (1)

Parts of forms that contain TemplateSlot are not evaluated until the keys mentioned in TemplateSlot[key] are bound to a proper value:

Layout  (4)

Put the result below the form:

Put the result above the form:

Specify a custom order:

Specify a different order for the initial form and the results:

Options  (6)

AppearanceRules  (1)

Write a custom title and description:

Use an image for branding:

Use an "ItemLayout" to change form fields' appearance:

Change the submit label:

FormLayoutFunction  (1)

A pure function can be specified to give a specific layout to a form:

PageTheme  (4)

Deploy a form with a white theme:

Deploy a form with a blue theme:

Deploy a form with a black theme:

Deploy a form with a red theme:

Applications  (2)

Draw the flight path between two airports:

Get demographic data for a city:

Properties & Relations  (9)

FormPage is designed to be interchangeable with FormFunction:

FormPage is designed to be interchangeable with APIFunction:

And vice versa:

The first argument of FormPage can be given as a full FormObject:

FormPage evaluates so that the first argument becomes a full FormObject:

The single fields of a FormPage use Interpreter to transform the input in Wolfram Language expressions:

This is effectively the same as:

AnySubset can be used to generate a controller where more than one choice can be picked:

RepeatingElement can be used to create a group of fields that can be added and deleted:

CompoundElement can be used to create an extensible table of fields:

Possible Issues  (1)

Interpreter["String"] accepts an empty string. This is not true for FormPage, where the empty string and an empty field are considered equivalent:

Neat Examples  (1)

Make a simple web application to apply a filter to an image:

Wolfram Research (2015), FormPage, Wolfram Language function, https://reference.wolfram.com/language/ref/FormPage.html.

Text

Wolfram Research (2015), FormPage, Wolfram Language function, https://reference.wolfram.com/language/ref/FormPage.html.

CMS

Wolfram Language. 2015. "FormPage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FormPage.html.

APA

Wolfram Language. (2015). FormPage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FormPage.html

BibTeX

@misc{reference.wolfram_2024_formpage, author="Wolfram Research", title="{FormPage}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FormPage.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_formpage, organization={Wolfram Research}, title={FormPage}, year={2015}, url={https://reference.wolfram.com/language/ref/FormPage.html}, note=[Accessed: 21-November-2024 ]}