Collection

Collections are a structural element you can use to group fields together so they can be repeated as a set. To use a collection, drag it onto the canvas and then drag fields into the collection.

Example: You want to gather the name, age, and gender of each of the form submitter's children. By placing these fields into a collection, the person filling out the form can click an "Add" button to input the name, age, and gender of more than one child.

Add link in a collection

Settings

To edit a collection

  1. Select the collection on the canvas, and the options will appear in the right pane.
  2. Under Field label, enter the name that will appear above the section on the form.

    Note: The header for a collection in a form is an h2 header, not an h1 header. Only the header of the form can be an h1 header.

  3. Under Variable, specify a name for the field variable associated with this field. If you do not specify a variable name, Forms will automatically assign the field one based on its label.
  4. Tip: If you added this collection as a variable from another form, and then edited the original collection by adding more fields, you can add those extra fields to this collection by clicking Add a field from variable.

  5. Under Text above field and Text below field, you can enter any additional text that should appear with the collection header. Click the Insert variable button to include a variable with this text.
  6. Under Set deletion, select Confirm deletion to ask a form user to confirm the deletion of a set.
  7. Under Collection View Settings, the following options are available:
    • Select Enable pagination to set the Pagination Page Size and control the number of sets displayed at one time.
    • Select Enable search to allow the user to search for data within the collection. The sets displayed will be limited to sets that contain data matching the entered parameter.
    • Select Enable filter to allow the collection data to be filtered through a custom filter dialog.
  8. To configure advanced options, click the Advanced tab.
    • Under Set settings, you can choose if a collection will have a fixed number of sets or if users can add sets.
      • Range of sets: Select this option to allow the collection to have a range of sets. This option is helpful in the following situations
        • If you want the collection to have a set minimum number of sets and then allow users add up to a maximum number of sets.
        • If the collection is being populated with data from a data source or a variable, then you might not know the exact number of sets being populated, so setting a range allows for some flexibility. In this situation, the minimum number of sets specified will always be displayed, even if you don't have enough values from the data source or variable to fill it (blank sets will be added until the minimum is reached). Users can always manually add sets up to the maximum number specified. If the number of sets returned by the data source or variable is the maximum number of sets or higher, the number of sets will be capped at the maximum, and users won't be able to add sets.
        • Tip: Leave the maximum value blank to return all sets from the data source or variable and let users add an unlimited number of sets.

      • Fixed number of sets: Select this option to specify the number of sets in the collection. If the collection is being populated from a data source or variable, the results will be capped at this number of sets. If fewer than this number of sets are returned from a data source or variable, the remaining sets will be left blank. Users cannot add sets with this option.
      • Append sets to the sets populated by a data source or variable: Select this option if you want to return all sets from a data source or variable and append sets to the bottom of that list. In the minimum text box, specify the number of sets that will be automatically added to whatever sets are returned by the data source or variable. In the maximum text box, specify the total number of sets that can be added to the sets returned by the data source or variable. Users will be able to add up to this number of sets by clicking the add set link. Set both these numbers to zero if you only want to display all the lookup or variable results and not let users add to the collection. If desired, change the Text for add set link value.

      Note: If the collection is a variable from another form, it is populated differently depending on whether it has lookup rules.

      • If a lookup is configured for the collection, the looked up values will replace all existing values.
      • If an auto-suggest lookup rule is configured and the suggestions are different than the variable values, the field will be blank.
      • If an auto-suggest lookup rule is configured and the variable has a value that is in the list of auto-suggested values, the value won't change.
      • If no lookup is configured for the collection, the variable values will be displayed according to the options configured above.
    • Under Tooltip, specify the help text that will appear when users hover over the field.
    • Under CSS classes, specify the CSS classes to assign this field. Learn more about using CSS.
  9. Select the Rules tab to create field rules specific to this field. Learn more about using rules.
  10. Your changes will be applied to the form automatically.
  1. Select the collection on the canvas and click Edit.
  2. Under Field label, enter the name that will appear above the collection on the form.

    Note: The header for a collection in a form is an h2 header, not an h1 header. Only the header of the form can be an h1 header.

  3. Under Text above field and Text below field, you can enter any additional text that should appear with the field. Click the Insert variable button to include a variable with this text.
  4. Under Variable, specify a name for the field variable associated with this field. If you do not specify a variable name, Forms will automatically assign the field one based on its label.
  5. Tip: If you added this collection as a variable from another form, and then edited the original collection by adding more fields, you can add those extra fields to this collection by clicking Add a field from variable.

  6. Under Collection options, you can choose if a collection will have a fixed number of sets or if users can add sets.
    • Fixed sets: Select this option to specify the number of sets in the collection. If the collection is being populated from a data source or variable, the results will be capped at this number of sets. If fewer than this number of sets are returned from a data source or variable, the remaining sets will be left blank. Users cannot add sets with this option.
    • Range of sets: Select this option to allow the collection to have a range of sets. This option is helpful in the following situations
      • If you want the collection to have a set minimum number of sets and then allow users add up to a maximum number of sets.
      • If the collection is being populated with data from a data source or a variable, then you might not know the exact number of sets being populated, so setting a range allows for some flexibility. In this situation, the minimum number of sets specified will always be displayed, even if you don't have enough values from the data source or variable to fill it (blank sets will be added until the minimum is reached). Users can always manually add sets up to the maximum number specified. If the number of sets returned by the data source or variable is the maximum number of sets or higher, the number of sets will be capped at the maximum, and users won't be able to add sets.
      • Tip: Leave the maximum value blank to return all sets from the data source or variable and let users add an unlimited number of sets.

    • Append sets to the sets populated by a data source or variable: Select this option if you want to return all sets from a data source or variable and append sets to the bottom of that list. In the minimum text box, specify the number of sets that will be automatically added to whatever sets are returned by the data source or variable. In the maximum text box, specify the total number of sets that can be added to the sets returned by the data source or variable. Users will be able to add up to this number of sets by clicking the add set link. Set both these numbers to zero if you only want to display all the lookup or variable results and not let users add to the collection.

    Note: If the collection is a variable from another form, it is populated differently depending on whether it has lookup rules.

    • If a lookup is configured for the collection, the looked up values will replace all existing values.
    • If an auto-suggest lookup rule is configured and the suggestions are different than the variable values, the field will be blank.
    • If an auto-suggest lookup rule is configured and the variable has a value that is in the list of auto-suggested values, the value won't change.
    • If no lookup is configured for the collection, the variable values will be displayed according to the options configured above.
  7. To configure advanced options, click the Advanced tab.
  8. When you are finished editing the settings, click Done. Your changes will be applied to the form automatically.

Using JavaScript with collections

In the classic form designer, you can use JavaScript to trigger custom dynamic behavior in collections. In the form designer, you can use the LFForm object.

Collections and variables

When you add an existing field to a collection, the field will lose its variable. Since a collection is a set of repeatable fields, the collection itself will have a variable with sub-values for contained fields.

Note: In Laserfiche Forms 10.2 and later, the Save to Repository Service Task supports process variables that can retrieve values from a specific row in a table or a set in a collection that can be used in a document name or template field. For example, design a table with a "single line" field and a "file upload" field. If the table has 2 rows of values, setting the file upload document name in the Save to Repository Service Task to {/dataset/Table_variable_name/Single_Line_variable_name[Row()]} will set the first file with the first row's value and the second file with the second row's value.