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?
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
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.