Hidden field

A hidden field is a valid form field that is neither visible to nor editable by the end user. Hidden fields are typically used to hold data that must be submitted when the form is submitted, but data that shouldn't be accessible to the user. For example, a hidden field might contain the date and time when a user agreed to, say, a legal acceptance. The user shouldn't be able to change that value: that value should only change when the user agrees to the acceptance. And because they can't change the value, there's no reason to display that information onscreen.


Hidden field attributes and terminology

The hidden field, like other [Identity Cloud fields, provides a number of attributes you can use when creating and formatting the field. Also like other Identity Cloud fields, the terminology used to represent these attributes in Console’s Registration Builder sometimes differs from the terminology required when using the Configuration APIs, which, in turn, sometimes differs from the terminology used if you view the underlying flow. 

Needless to say, that can be confusing at times. With that in mind, the following table shows the different hidden field attributes and how they are referenced in Registration Builder, the Configuration API, and the flow; click the appropriate link in the flow column for more information about that attribute. Attributes highlighted in yellow are auto-generated when the field is created, and shouldn’t be referenced when making an API call (and can’t be accessed through Registration Builder).

Option used in Registration BuilderMember used when making an API callProperty name used in the flow
Namenamename
Field Typetypetype
Schema AttributeschemaAttributeschemaId
Default Valuevaluevalue
Submit blank field values as nullemptyMeansNullemptyMeansNull
Ignore updates submitted to this fieldignoreUpdateignoreUpdate
Formsformsforms
Data Validationvalidationvalidation
element

Create a hidden field by using the Configuration API

If you’re using the Configuration APIs to create a hidden field, you must include all the desired attributes and attribute values within the request body of your API call. Your request body will look similar to the one shown below (depending, of course, on the number of attributes you use). In the following example, required attributes are shown in red:

{
     "**name**": "testFieldHidden",
     "**schemaAttribute**": "primaryAddress.company",
     "**type**": "hidden",
     "forms": [
         "traditionalRegistrationForm"
     ],
     "shouldUpdate": false,
     "ignoreUpdate": false,
     "emptyMeansNull": true,
     "value": "null"
}

If you’re using Postman, your request body will look like this:

There are at least two things to keep in mind when creating the request body:

  • The request body must be formatted using JSON (JavaScript Object Notation). If you get the following error, that often means that your request body isn’t using valid JSON:
400 Bad Request. The browser (or proxy) sent a request that this server could not understand.
  • The forms attribute must be formatted as a JSON array, with the form names configured as a comma-separated list between square brackets. For example:
"forms": ["traditionalRegistrationForm", "socialRegistrationForm"]

A complete Curl command for creating a hidden field will look similar to this:

curl -L -X \
  POST 'https://v1.api.us.janrain.com/config/79y4mqf2rt3bxs378kw5479xdu/flows/fieldExamples/fields' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Basic eTR4Zmc2ZjQ0bXNhYzN2ZXBqanZ4Z2d6dnQzZTNzazk6OTVjY3hrN2N6YnZ1eng2ZHB0ZTVrOXA2ZGo1Ynpla3U=' \
  --data-raw '{
    "name": "testFieldHidden",
     "forms": [
         "traditionalRegistrationForm"
      ],
    "schemaAttribute": "primaryAddress.company",
    "shouldUpdate": false,
    "ignoreUpdate": false,
    "emptyMeansNull": true,
    "type": "hidden",
    "value": "null"
}'