Infopath Conditional Formatting: Show/Hide Optional Section via Checkbox or Radio Buttons

admin

I don’t know why it took me so long to figure this out, but it took me FOR-E-VER. I created a browser enabled Infopath form with Infopath 2007 (form is compatible with Infopath 2003) which I published to a SharePoint library with approval workflow on the library.  While the form came out quite nicely, I had wanted to make it easier to fill out by adding conditional sections to the form. E.g., if checkbox A is checked, show Section B. I had read all kinds of posts on forums and Microsoft tutorials that explained how to toggle visibility of a section of a form based on whether a checkbox or radio button is selected.

All posts and tutorials explained nicely how to set the conditional formatting of the section to make the “Hide this control if the above conditions are met” logic work, but no matter how often I tried—it just wouldn’t work.  I was about to give up when, probably on my last try, I modified another setting. Up until now I had assumed that if I want to hide a section, I should set it to “Do not include this section in the form by default.”

Well, I could be the only person on this planet who would think that this would work, but if I am not, and you also have problems getting your conditional formatting on your infopath forms to work—this is what solved my problem: Make sure that the section properties of your hidden section are set to “Include the section in the form by default.”

Infopath Section Properties dialog box with correct setting

Infopath Section Properties dialog box with correct setting

I often get the question how to make a section visible by selecting a radio button rather than hiding a section. Since InfoPath conditional formatting only allows you to hide something if a certain condition exists, I thought I would show how to work with that logic. So let’s assume you have a radio button with Yes/No choice and you want to show a section only if Yes is selected. You would have the following settings on your “Yes” radio button:

  • Data type: True/False (boolean)
  • Value when selected: True
Option button properties for the "yes" radio button

Option button properties for the "yes" radio button

In my form, this is a required field, so I also selected the “Cannot be blank” checkbox.

To show a form section (mine is called group 7), when yes is selected,  I set the following in the Display>Conditional Formatting settings of the section properties for group 7: ReqIsProjectRelated is not equal TRUE and select the checkbox for “Hide this control”. This means that unless somebody selects Yes as the radio button value, the section “group7” will remain hidden on the form.

screenshot of dialog window for conditional formatting of section

screenshot of dialog window for conditional formatting of section

8 Comments. Leave new

thanks this was very helpful, i had this on my form previously, deleted it then forgot how i did it, with your help i was able to recreate it better

Approval/Feedback workflow: how to change the task status with a custom button on InfoPath Form? | DL-UAT
Saturday February 28th, 2015 03:36 AM

[…] inclusivedesignsolutions.com link […]

I have the same problem as Brenna. We don’t want to hide the section on “the select of a spesific option of a radio button”. We want to make it visible. Can you please tell me how?

Marise,
To make a section visible, you just switch the way you think about something being visible (it’s just the opposite of not being hidden), since your only option is to select the checkbox for “Hide this control”. So to achieve making a section visible when a radio button of value “yes” is selected, you would hide the control as long as this is not the case. So your logic is:
If radio button (fieldname) is not equal to TRUE, then hide this control (this logic checks to make sure the “Yes” radio button is not selected). This means that the control is hidden when the form loads (because “Yes” is not true), and will become visible as soon as somebody selects “Yes” for your radio button, because the condition “is not equal to true” no longer applies. I assume you have a radio button with Yes/No options and that the value for Yes is TRUE and the value for No is FALSE in your radio button properties? Let me know if you need a screenshot for this and if it doesn’t work for you, tell me a bit more about your radio button: does it have a pre-selected value? What is the name of your radio button and the section you want to hide?

I am also trying to make the value of one field cause another section to display and the steps above did not work for me. My field that I want to use as a condition for a section to appear is a yes/no so a 1 or 2 value.
What I get is that the conditional section appears by default and only disappears if the user clicks on “no”. I don’t want the section to appear at all unless “yes” is checked.
Can you help?

Brenna,
To accomplish this, I assume you use radio buttons.

-Make sure that both the yes and no radio button use the same field name.
– As field type, select “True/False (boolean)”.
-Set the “Value when selected” field to True for yes and False for no.
Important: make sure non of the two radio buttons has the checkbox “This button is selected by default” selected!

Then double-click on your section and in the Section Properties
-in the Display tab, click “Conditional Formatting” and add a condition with the following settings:
first dropdown: select your radio buttons field name
second dropdown: select “is not equal to”
third dropdown: select “TRUE”

-Then check the checkbox “Hide this control”.

Not sure if you figured this out by now, I wasn’t around when you posted. I just created your scenario in Infopath and had no problems. Here are the steps that worked:
1. I created a textbox and set the field name to age by double-clicking the text box(I assume you did this and don’t rely on the text box label, right?)
2. Below the text box, I added a conditional section and typed in some text.
3. I double-clicked the conditional section and selected “Include this section by default” from the section properties.
4. Under the section properties Display tab, I clicked the “Conditional Formatting” button
5. In the conditional format dropdowns, I selected age from the dropdown (it must be there if you have a field in the form with that field name) and selected “is less than” and typed 16 in the third drop-down.
6. To make it work, I checked the Hide this Control checkbox.
7. Previewed the form and when I typed in 18 in the text box and moved the cursor focus out of the field, the conditional section showed up as designed.

Okay this got me partway, what still confuses me is how to set the optional section to display based on a value input by the form user. I have two questions, the answer to the first if greater then 16 needs to display the optional section. Called the text box Age. Then created an option section, checked show by default, created my table, added the second question, all is good so far. Now when I got to the optional section conditional formatting, there is no way to select the box Age as the first argument! Somehow the first question and the optional box do not even know the other exists. What am I doing wrong!