Infopath Conditional Formatting: Show/Hide Optional Section via Checkbox or Radio Buttons
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.”
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
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.