Set default values

Fill fields in the form with default values

You can define default values (sometimes also called start values) for many field types in Visforms. These are values that are already entered in the form when a user opens the form. As a rule, default values are used to relieve the user of work when filling out a form. The user has the possibility to change these values if necessary. If the default value is not changed by the user, it is also automatically transmitted with the form.

Default values are not placeholders

Please do not confuse the default value with a placeholder. Also, when a user opens the form, placeholders are also displayed inside the input field. However, placeholders serve to give the user a hint as to what type of input he should make in the field. This is particularly important if the form field does not have its own label. If the user clicks in the input field, the placeholder disappears. Placeholders are not real data in a form field and are never transmitted with the form when it is submitted. Visforms also offers you the possibility to display placeholders.

Field configuration or URL

Visforms offers you two different ways to fill fields with default values. On the one hand, you can define specific default values in the field configuration. For example, the email address of the registered user or the current date. On the other hand, you can also dynamically set default values in the form using URL parameters. This entry describes how to set default values using the field configuration. The use of URL parameters is described in this article: Default values as URL parameters.

The individual field types

Hidden

Hidden fields are not visible in the form interface. Consequently, a user cannot type in a “hidden” field. You can use Hidden fields to submit information of your choice along with user input in the form. To do this, simply provide a “hidden” field with a default value.

For fields of the “Hidden” type, Visforms offers you the option of creating any free text as the default value. Enter this in the “Value” option and set the “Fill field with” option to “Start value”.

Default value for field type hidden

In “Fill field with” select the option “Start value + Unique ID”, then Visforms will generate a long, unique ID for each record. Visforms appends this to the start value stored in “Value” and transmits this combined text as the value of the hidden field with the form.

User data as default value for field type hidden

Alternatively, you have the option of using the data of the logged-in user as default values for a “Hidden” type field. Here you can choose from the following values from the user profile. Select the appropriate option under “Fill field with”:

  • Name
  • Username
  • Address 1
  • Address 2
  • Location
  • State
  • Country
  • zip code
  • Phone

Joomla offers the possibility to create individual “Custom Fields” in the user administration. Data of the logged-in user from “User-Defined Fields” can also be used as a default value in the form. All custom fields of type “Text” are automatically available in the “Fill field with” drop-down list.

You also have the option of using an SQL statement to determine the default value of the field. To do this, select the “Value from individual SQL statement” option under “Fill field with”. For the “Default value SQL statement” option, add a select SQL statement that returns exactly one value.

You can use placeholders in the SQL statement, which are replaced with real values at runtime. On the one hand, these can be values from the Joomla user object, the current Joomla user, or values from the current Joomla input object. Joomla User Object placeholders have the format ${user:parametername}. For example, ${user:id} for the current user’s id. Placeholders of the current input object have the format ${input:parametername}, where you need to replace “parametername” with the name of the input parameter you want to use.

Note: The use of data of the registered user and of SQL statements in default values is part of the Visforms Subscription and not included in the free Visforms version.

Text

Default value for field type Text

For fields of the “Text” type, Visforms offers you the option of creating any free text as the default value. Enter this in the “Start value” option and set the “Fill field with” option to “Start value”.

Alternatively, you have the option of using the data of the logged-in user as the default value for a text-type field. You can choose from the following values from the user profile:

  • Name
  • Username
  • Address 1
  • Address 2
  • Location
  • State
  • Country
  • zip code
  • Phone

If the form is opened by a visitor to your website who is not logged in, then the data of a logged-in user will not be available. In this case, of course, only text fields for which a start value is set and the “Start value” setting is selected in the list box are filled with a default value.

Joomla offers the possibility to create individual “Custom Fields” in the user administration. Data of the logged-in user from “User-Defined Fields” can also be used as a default value in the form. All custom fields of type “Text” are automatically available in the “Fill field with” drop-down list.

You also have the option of using an SQL statement to determine the default value of the field. To do this, select the “Value from individual SQL statement” option under “Fill field with”. For the “Default value SQL statement” option, add a select SQL statement that returns exactly one value.

You can use placeholders in the SQL statement, which are replaced with real values at runtime. On the one hand, these can be values from the Joomla user object, the current Joomla user, or values from the current Joomla input object. Joomla User Object placeholders have the format ${user:parametername}. For example, ${user:id} for the current user’s id. Placeholders of the current input object have the format ${input:parametername}, where you need to replace “parametername” with the name of the input parameter you want to use.

Note: The use of data of the registered user and of SQL statements in default values is part of the Visforms Subscription and not included in the free Visforms version.

email

Email type fields work very similar to Text type fields. See also the fields of type Text above. You can set a fixed email address as the default value.
Having a Visforms Subscription allows you to fill in the default value

  • with the email of the registered user or
  • a value that was determined using an SQL statement.

Date

Default value for date field type

For fields of the Date type, you can either specify a fixed date as the default value or, alternatively, always use the current date. To do this, select the option “Selected date value/Current date” under “Fill field with”. If you now enter a value for “Selected date value”, this will be used as the default value. If you tick the “Current date” checkbox and leave the “Selected date value” empty, the current date is always used as the default value.

Note: If a value is set for 'Selected date value', then this always trumps the setting of the checkbox 'Current date'.

The Visforms Subscription Features gives you two more options. You can set a date as the default value that is shifted by a specified number of days in the future or in the past relative to the current date. And you can use an SQL statement to determine a dynamic default value. More on this in: Additional options for date fields

Number, URL

Default value

You can specify a fixed default value for fields of the Number and URL type. Select the “Start value” option for “Fill field with” and enter the desired value in the “Start value” option input field. The Visforms Subscription also offers you the option of using an SQL statement to determine a dynamic default value.

Password, text area

Default value

You can specify a fixed default value for fields of the type Password and Textarea. Enter this in the input field of the “Start value” option.

Checkbox, checkbox group, radio button and list box

Checkboxes, checkbox groups, radio buttons and list boxes are field types in which a user cannot make any free entries. The user can only ever select from predefined values. By definition, these field types always have a more or less long list of possible default values. These are the values you enter for a checkbox in the “Value” option and for checkbox groups, radio buttons and list boxes in the “Options List”.

You can find more information about checkbox groups, radio buttons and list boxes in this article: Listbox, Radios and Checkboxes.