13

I have the requirement to create two lists: the second one being dynamically populated with Sitecore data after the user selects a value from the first one. I tried using some Rules for WFFM but can't seem to match any with what I want to have as results.

I would like to have something like countries in the first list. After selecting a value, the second list will dynamically populate the regions depending on the country selected - if the country has regions, else a N/A single element will be added.

What is the best way and approach for doing this dependent drop lists functionality for a WFFM form (Sitecore 8.1 - webforms)?

  • 3
    I suspect you're going to need some custom field types to achieve this. Bolt in some JS that calls a back-end REST service to populate the drop-downs, or if there are only a small number of permutations, send all the data in a JSON block to the glass and let JS do the work of re-populating the drop-downs. A couple of decent blogs on the topic include Creating a custom field type in wffm for sitecore and WFFM Session Aware Single-Line Text Field – Richard Hauer Sep 16 '16 at 1:34
  • Yes totally agree with Richard Hauer, I also had the same requirement to populate states according to country selection in WFFM, what I did is I have created 2 Dropdown fields in WFFM and hide states DD. And with the help of javascript I have populated country list in DD, and on the selection of country, I used JSON to show appropriate state DD. – Gaurav Agarwal Sep 19 '16 at 16:51
  • @GauravAgarwal how did you passed the invalid state error on submit? I also did the implementation of WFFM dependent droplist by using js but now I get a invalid state error on postback of the form since the droplists are populated via js and not in code. Is there a way you managed to bypass that error? – Adrian C. Sep 20 '16 at 7:08
3

I'm sure I came across an example of linked drop downs in WFFM in the past but can't find find it now. This might be a good basis to start from: http://sitecoreguild.blogspot.co.uk/2013/06/sitecore-country-and-region-dropdowns.html

However you will obviously need to inherit from the right classes for your dropdowns to work, there is a good example here: https://divamatrix.wordpress.com/2011/12/20/wffm-custom-field-type-made-easy/

  • 2
    There isn't any substance to this answer, merely external links. I don't believe this meets the guidelines for a good answer. – jrap Jul 21 '17 at 1:44

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.