Toggle menu

Form Field Blocks

These blocks work with fields and their values. The blocks you have available will depend on whether your script is executed client-side or server-side (because, for example, hiding or setting focus to a field doesn't make sense sever-side). The icons in the top-right of the editor will let you know where your script is going to be executed, see the introduction to Blockly Blocks for more information.

Showing and Hiding Fields

Show and Hide Field
 

These blocks show or hide a field.

Get a Field's Value

The value of a single field, a field on an instance, or all values
 

These blocks return the value of another field. Pick the field you'd like to query.

The first block queries a single field on a single page. The second gets the value of a field on a particular page instance. The third returns all of the values of a field on a repeating page as an array, if there are multiple instances, or a string if only a single instance exists.

Get All Field Values

Get Field Values
 

These blocks return the values of all of the fields on a page. If there is only a single instance of a page, the values are returned as an object, if there are multiple, an array of objects is returned. Field names and values make up the key-value pairs in each object.

Updating Fields

Updating Field Values
 

The first of these blocks behaves slightly differently depending on where you use it. When working client-side (for example in field handler functions) you can only select a field on the same page as you are working. When you are working server-side (eg in default functions) the block can be used to select any field on any page of the form that has already been visited.

The second block updates the value of a field on an instance of a repeating page. It can only be used server-side.

Filter Options

Filter Options
 

This block will filter the options in a list field, only displaying the items in one or more named groups. There's an example of this in the .filterOptions helper function article.

Plug in another block that has a list of group names (comma separated) you'd like to use to filter the list.

Displayed Options

Displayed Options
 

Returns the options currently being displayed in the checkbox group, drop-down, list box and radio group fields.

Invoking a Field's Custom Function

Invoking Custom Field Functions
 

Several fields have custom functions that can be triggered from other fields. The location picker can show or hide its map, or perform a search; the HTML template fields can be made to re-render their HTML templates; the accordion layouts can expand or collapse.

The example above shows the search function of a location field being invoked. It will be passed the value of another field as the thing to find on the map. You can pass more parameters to the function by pressing the blue cog icon.

Required and Optional Markers

Show and Hide Markers
 

Fields can be marked as required (generally with an asterisk next to their label) or as optional. These blocks show and hide those markers. It is not possible to display a field as both required and optional.

Note these blocks only update the marker next to the field label, they don't toggle a field's "requiredness" on and off. To do that use the validation function.

Field Name and ID

Current Name and ID
 

These blocks return the name and ID of the current field. The name returns exactly what is entered into the forms designer. The ID has the format <FORMNAME>_<PAGENAME>_<FIELDNAME>

Further Examples

The The Form Helper Library article in the knowledge base has example forms that show all of the other core field blocks being used.

Last modified on 15 November 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon