You are here

function webform_options_example in Webform 7.3

Same name and namespace in other branches
  1. 6.3 webform.api.php \webform_options_example()

This is an example function to demonstrate a webform options callback.

This function returns a list of options that Webform may use in a select component. In order to be called, the function name ("webform_options_example" in this case), needs to be specified as a callback in hook_webform_select_options_info().

Parameters

$component: The Webform component array for the select component being displayed.

$flat: Boolean value indicating whether the returned list needs to be a flat array of key => value pairs. Select components support up to one level of nesting, but when results are displayed, the list needs to be returned without the nesting.

$filter: Boolean value indicating whether the included options should be passed through the _webform_filter_values() function for token replacement (only) needed if your list contains tokens).

$arguments: The "options arguments" specified in hook_webform_select_options_info().

Return value

An array of key => value pairs suitable for a select list's #options FormAPI property.

Related topics

File

./webform.api.php, line 85
Sample hooks demonstrating usage in Webform.

Code

function webform_options_example($component, $flat, $filter, $arguments) {
  $options = array(
    'one' => t('Pre-built option one'),
    'two' => t('Pre-built option two'),
    'three' => t('Pre-built option three'),
  );
  return $options;
}