0

I have a select input that's pulling it's options from one of our site's vocabularies. I'd like, however, to alter the options to include a data attribute based upon a custom field within the term.

The input looks like:

$form['my_sample'] = [
  '#type' => 'webform_term_select',
  '#title' => t('Sample Reason'),
  '#vocabulary' => 'sample_reasons',
  '#tree_delimiter' => '- ',
  '#empty_option' => t('Make A Selection'),
  '#select1' => TRUE,
];

I tried hook_webform_options_alter(), but that wasn't the right approach.

How do I alter/add to the select options in this scenario?

Your Answer

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

Browse other questions tagged or ask your own question.