This is very similar to this issue:
http://drupal.org/node/1180454
It seems that when that issue was fixed, only options entered manually into the allowed values text area were corrected. The exact same problem persists if a select box uses values returned by hook_webform_select_options_info() that are grouped:
for example:
array(
'group one' => array(
851 => "Readable title"
852 => "Readable title Two"
853 => "Readable title Three"
),
'group two' => array(
551 => "Title"
552 => "Two"
553 => "Three"
)
);
will return integers in the CSV exports and emails associated with the values, even if you set the CSV options to use the "ull, human-readable options (values)" option in the select list configuration of data download.
What was done in this issue http://drupal.org/node/1180454 that can be done to fix the problem with PHP values?
thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | webform_hook_options_docs.patch | 3.53 KB | quicksketch |
Comments
Comment #1
quicksketchThis is actually merely a documentation bug. We already have a $flat parameter that is passed into your options callback function, you just have to obey it to eliminate this problem.
You also have arguments for $component (the webform component), $filter (if you should run _webform_filter_values() on the options), and $arguments (which passes your arguments down that you specified in hook_webform_select_options_info(), if any).
Comment #2
tmsimont commentedyes! thanks quicksketch.
also fyi to anyone else out there. the code quicksketch put up didn't immediately work for me because array_merge() does not maintain the associative array keys. instead of what quicksketch put up, do this:
Comment #3
quicksketchAh, fair enough. array_merge() actually maintains associative keys unless they're numeric (like your example). Anyone else using this code, also be sure to actually include this at the bottom of the function:
Otherwise you're not going to get anything back :)
Comment #4
quicksketchI've committed this patch which updates our documentation. It also lists the arguments for the callback functions in webform.options.inc, even though none of those actually need to use any of them. That should make it so that other developers looking for examples will at least know that those arguments exist and will hopefully go read the documentation.
Comment #5
quicksketch