A client came to us and asked if there were a way to allow a supporter to choose from a list of custom fields if an optional group was checked. For example, if the supporter clicked on the Cheese optional group here:
Then the supporter would be prompted with cheese-related custom fields, like this:
Cool, huh? All of the custom fields that are specific to a particular group are hidden until the supporter chooses to choice the group. Like that? Read on!
The solution is to add and configure a script that moves the custom fields below the associated group.
Before you begin
With these items in hand, I created a single group matching that looked like this:
group 97032 contains API names cheddar, danisfarmcheese, gouda, longhorn
If there were more optional groups that needed to have extra fields, then we'd repeat that step until they were all configured.
Okay, configuration is done, let's go install stuff!
You can use these steps to install the script: You'll need to install this script in all of the templates where groups are going to be associated with custom content fields.
- Edit the template.
- Locate the </body> tag by using the browser's search tool.
- Insert a blank line just before the </body> tag.
- Click here to see the solution.
- When the window opens, click on the Raw button. That will open another window that contains only the solution text.
- Copy the solution text and close the window.
- Paste the copied text into the newly inserted line in the template.
Okay, installation is done. Now to configure the groups.
This section shows how to configure the data used by the script. The data is housed in some hidden HTML that appears just after the script. Remember when we did the data gathering at the top? This is where it will be applied.
Please use these steps for each group that you collected.
- Locate the "Configuration" section at the bottom of the newly pasted text.