Insert an optional section

If you have a section on your Microsoft Office InfoPath form template that is relevant only to certain users, consider making it an optional section. An optional section does not appear on the user's form by default. Users insert and fill out the optional section only if they need it.

In this article

When to use an optional section

The user experience

Insert an optional section

Customize the hint text that users click to insert the optional section

Show the optional section on the form by default

Layout tips

When to use an optional section

Use an optional section when you want to offer users the choice to fill out a particular section of the form. For example, on a status report form template, you can include an optional Notes section. Users who want to add supplementary notes can insert and fill out this optional section. Everybody else can leave the section hidden.

Optional section used to collect notes

When you insert an optional section onto your form template, you are essentially inserting an empty container. For the section control to be useful, you must insert other controls inside it. In the previous example, the form designer inserted a rich text box inside the optional section, along with a Notes heading.

Related controls

InfoPath includes other controls that are similar to optional sections but that serve different purposes. To decide which of these controls works best on your form template, refer to the following list:

Section    Sections are used to organize groups of related controls. Sections appear on the form template by default. You can't choose to hide them as you can with optional sections.

Repeating section    To create a section that users can insert onto a form multiple times (such as a record in a database), use a repeating section or another repeating control.

Choice group    To insert a section that can be replaced with another section, use a choice group. A choice group contains two or more sections. By default, one of these sections appears on the form. Users can choose to replace it with a different section. Choice groups can also be inserted on a form multiple times by the user.

Top of Page

The user experience

If you left the default settings enabled for your optional section, users will see a small orange arrow icon next to some hint text when they open a form that is based on your form template. You can customize the hint text when designing your form template.

Hint text for optional section

If they click either the icon or the hint text, InfoPath replaces the hint text and icon with the optional section. The user can then enter data into the controls inside the optional section.

To remove an optional section, users move their pointer over the section until an orange shortcut menu button appears in the upper-left corner. Users click this button to see a menu of options for working with the section. You can customize the menu commands when designing your form template.

Remove Notes command on shortcut menu

Note: If a user removes an optional section after filling it out, the data in that section is lost, not hidden.

Top of Page

Insert an optional section

The procedure for inserting an optional section differs slightly depending on whether you are designing a new, blank form template or basing the design of your form template on a database or other external data source.

The following illustration shows how an optional section looks when it is selected in design mode.

Empty optional section selected in design mode

Controls can be bound or unbound. When a control is bound, it is connected to a field or group in the data source so that data entered into the control is saved in the underlying form (.xml) file. When a control is unbound, it is not connected to a field or group, and data entered into the control is not saved. When you select or move your pointer over a control, text and a binding icon appear in the upper-right corner of the control. The text indicates the group or field to which the control is bound in the data source. The icon indicates whether the control is correctly bound to that group or field. When the binding is correct, a green icon appears. If there's something wrong with the binding, you'll see a blue or red icon instead.

The data source for the form template consists of fields and groups that appear in a hierarchical view in the Data Source task pane. Optional sections are always bound to groups in the form template's data source. Each control in an optional section is bound to a field that is part of the section's group.

In the following example, the Notes optional section on the form template is bound to the notes group in the Data Source task pane.

Relationship between optional section in form template and group in data source

Insert an optional section on a new, blank form template

When you design a new, blank form template, the Automatically create data source check box in the Controls task pane is selected by default. This enables InfoPath to automatically create fields and groups in the data source as you add controls to the form template. These fields and groups are represented by folder and file icons in the Data Source task pane.

  1. On the form template, place the cursor where you want to insert the control.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Under Insert controls, click Optional Section.

  4. To add controls to the section, drag the controls that you want from the Controls task pane into the optional section on your form template.

    Note: You should not move a control that is already on the form template into the section, unless the control's field is already part of the section's group in the data source. Otherwise, the binding for the control may break.

  5. To add a label to the control, type text above it.

Insert an optional section on a form template that is based on an existing data source

If you base the design of your form template on an existing Extensible Markup Language (XML) file, database, or Web service, InfoPath derives the fields and groups in the Data Source task pane from that existing data source. In this scenario, you can add an optional section either by dragging a group from the Data Source task pane to the form template or by inserting the section by using the Controls task pane, as described in the following procedure:

  1. On the form template, place the cursor where you want to insert the control.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Under Insert controls, click Optional Section.

  4. In the Optional Section Binding dialog box, select the group in which you want to store optional section data, and then click OK.

  5. Add controls to the section, and then bind them to the appropriate fields in the data source.

Top of Page

Customize the hint text that users click to insert the optional section

When you insert an optional section on your form template, "Click here to insert" hint text appears on the form. This text informs users that there is an optional section available for them to insert. Do the following to customize this text:

  1. Double-click the optional section.

  2. Click the Data tab.

  3. Select the Show insert button and hint text check box, and then replace the default text in the box with text of your own.

Top of Page

Show the optional section on the form by default

By default, optional sections are hidden when users first open a form. If you want to, you can choose to show an optional section instead. If you do this, InfoPath hides the "Click here to insert" hint text, because the optional section is already visible on the form.

  1. Double-click the optional section.

  2. Click the Data tab.

  3. Under Default settings, click Include the section in the form by default.

  4. Select the Allow users to delete the section check box.

Top of Page

Layout tips

Before you insert controls onto an optional section on your form template, think about how you want to arrange those controls. You can add text boxes and other controls by dragging them into the optional section wherever you want. Or, if you want more control over the layout, you can add a layout table inside the optional section and then insert labels and controls inside the individual cells so that they align nicely. In the following illustration, a four-row, two-column layout table is used to arrange labels and controls in the optional section.

Layout table used to arrange controls in optional section

In addition to using layout tables, you can do one or more of the following:

  • To change the size of several sections at once, select the sections whose size you want to change, press ALT+ENTER, click the Size tab, and then make the necessary adjustments.

  • To change the border or color of a section, select it on the form template, on the Format menu, click Borders and Shading, click the Borders tab, and then make the necessary adjustments.

  • To see how the controls in your section will look with actual text in them, click Sample Data on the View menu. This helps you get a sense of what a form based on your form template will look like when a user fills it out.

  • On occasion, the text inside the controls in a section and the labels to the left of those controls may appear to be slightly out of alignment. To quickly realign them, double-click the control, click Align on the Size tab, and then click Apply. If the label and control are in different cells in a layout table, right-click the cell that contains the label, click Table Properties on the shortcut menu, and then click Center under Vertical alignment on the Cell tab.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×