We work with schoolchildren in Florida, US. Schooling here is grouped into Elementary (grades 1 thru 5), Middle (grades 6 thru 8) and High School (grades 9 thru 12). I have a webform that asks the grade and the school, where school is a dropdown with too many choices. Is there a way to limit the choices in the school dropdown to those that offer the grade entered?

School facilities in our CiviCRM are Organization contacts with tag(s) indicating the grade grouping(s) each serves. Most school facilities serve only one grouping, but some serve all groupings (Elementary, Middle and High).

  • Clarifying that the CMS is Drupal 7. – SRQ_civicrm Dec 3 '19 at 19:23
  • would it help if you used Parent Tags (as I recall doing some nifty filtering in the past in webforms for Tags based around setting the Parent Tag rather than the tag itself - forget the detail so may not be relevant) – petednz - fuzion Dec 4 '19 at 3:37

If you use Drupal's webform (with webform civicrm to integrate civicrm), you can use the "webform conditionals" function.

Alternatively, you could create some custom javascript for the form.

  • Thanks Alan. I am familiar with webform conditionals but can't think of a way to use them in this case. The CIVI tab in the integrated webform offers the option to filter the list of School contacts by a tag, but as far as I can tell that's a static filter. Is there a way to interact with that filter from webform conditionals? Or did you have something else in mind altogether? – SRQ_civicrm Dec 3 '19 at 19:22
  • Correction, the Filters feature is in the webform element itself, not in the CIVI tab. The issue still is that I don't know how to interact with that Tags filter via conditionals. If you were thinking of another approach altogether, I'm all ears! – SRQ_civicrm Dec 3 '19 at 19:41
  • Got it to work with conditionals. The trick was to have separate contacts in the CIVICRM tab of the webform, one for each of Elementary, Middle, and High school. The conditionals just make sure that only the webform element linked (and filtered) to the grade-appropriate schools is shown. Cumbersome and maybe not broadly applicable, but it's the only way I could get it to work. Thanks! – SRQ_civicrm Dec 4 '19 at 23:54
  • Well done! Conditionals are hard to maintain when they get complicated, but unless you want to maintain custom code, it's often the only option for site-builders. – Alan Dixon Dec 5 '19 at 15:17

If you have Drupal, I highly recommend Alan's answer. If you are a WordPress user, there is a Gravity forms CiviCRM integration. I know that Gravity forms can do the conditional show/hide like Webform can. I do not have experience on the CiviCRM integration.

Another option is to have the initial page with buttons for Elementary, Middle & High Schools. Once they select that, they can see the form for that range with just their list of schools available in the dropdown. Not as slick as the conditional function but very doable.

  • I asked Alan for his thoughts on how to do this w. conditionals. That'd be my preferred approach, just can't think how to make it work. Re. an initial page w. multiple buttons, what would be the mechanics? Feels like I'd need to either 1) jump to a subsequent page break in the form based on the selection, but the page break element in webform allows only one "next" - or 2) redirect to another form, but that'd require multiple submit buttons and I don't know how to do that. Thank you for bearing w. me! – SRQ_civicrm Dec 3 '19 at 20:14
  • I think your asking how to make conditionals work... On your form, 1st question is Grade. Then make 3 Questions for School each with a specific dropdown list by grade group. Then under conditionals, show School Elementary if question 1 fits that, show School Middle if question 1 fits that, etc. You can even show other questions based on grade range as well. – Iowa Boy Dec 4 '19 at 3:06
  • To do the multi button option, you would build 3 completely separate forms, one for elementary, one middle, and High School. Then you would have an initial page that would have the buttons to direct them to the correct form. Again, the conditionals that Alan suggested is your best option. – Iowa Boy Dec 4 '19 at 3:14
  • I translated the "three questions" into three separate contacts in the CIVICRM tab of the webform. That made it work with conditionals. If you meant something simpler, I'm all ears! – SRQ_civicrm Dec 5 '19 at 0:02

For WordPress I think there is more integration/options with Caldera Forms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.