0

I'm trying to populate dynamic content in the select options like depending upon the country it should populate Country related states. I want this thing to be done by using web forms only.

I'm Using Drupal-7.60 Version.

Can we able to do that?

2 Answers 2

1

you can use any one module from below list. It will helpful in your case

1) https://www.drupal.org/project/webform_term_opts
2) https://www.drupal.org/project/webform_conditional

Sign up to request clarification or add additional context in comments.

2 Comments

need to install both?
both are not working Giving error while adding second select option
1

My best option is to use the hook_webform_select_options_info() to define a callback that can be used as select list options as bellow :

function mymodule_webform_select_options_info() {
  $items = array();

  $items['my_dynamic_custom_options'] = array(
    'title' => t('My dynamic custom options'),
    'options callback' => '_get_dynamic_custom_options',
  );

  return $items;
}

Then you need to provide the function for the callbacks that you specified above :

function _get_dynamic_custom_options() {
  // Get your options based on the logic you wants.
  // For example you can get options based on a taxonomy vocabulary terms.
  $options = array();
  $options['key'] = 'value';
  return $options;
}

Usage :

Clear your caches, and in your webform, under : ("Form Components" > "Select options". > "Add" > "Load a pre-built options list"), you'll find the option 'My dynamic custom options' defined above.

Hope this will help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.