When pulling data into an actual View to manipulate from this module (with Data / Schema) I noticed all of the selects are keys and not the labels. Is it possible to get the labels instead? If not, this would be very useful because key numbers (what I use it identify them) aren't all that useful to display.

I am using Views Bonus to export to a CSV file from my resulting view and the key values aren't what is needed there.

Comments

Anonymous’s picture

Upon looking at this further I'm not sure this is possible since this module uses a real database view. To unserialize the select label from the webform component table you need an intermediary step, but a view pulls everything from a query immediately.

I've searched and there is no way to unserialize data from SQL statements directly so I don't think this is going to happen (unless someone smarter than me figures it out somehow).

investigacoes’s picture

Same issue here!

johnnydigit’s picture

I was poking around, looking at the various hooks, and I thought of a way this could be done, but it might be a lot of work.

Webform MySQL Views could maintain a database table called, for example, webform_views_submitted_data_cache, using hooks hook_webform_submission_insert, hook_webform_submission_update, hook_webform_submission_delete to mirror webform_submitted_data with the display data for submitted webforms.

Then, because sometimes I like having the keys, two views could be created:
- webform_views_{my_table} would reference webform_submitted_data as it does now.
- webform_views_cached_{my_table} would reference webform_views_submitted_data_cache

I was looking at the possibility of creating this code myself, but I'm new to Drupal and still getting comfortable with PHP

taggartj’s picture

Title: Obtain select labels for views » Obtain select labels for views - and exposed filters

ok love this module! I Had the same issue with mult-select items - and needed to filter the results
as you only get the key values.



such as if the people select
a|red
b|green
1a|blue

mysql webfom views outputs . .the key values in this case (a, b, 1a ... if the dude select's thease values)
I needed to have thease options also

in my webform I had a file (image ) upload - and the out put is the file # ( I got access to this by adding a relationship in the data module to joins files.fid which then gave me access to the file..sory that is another story )

I dont know if I am right - but the following worked for me so I guess I am right.
I did the normal views things but I excluded the feilds from display with the multy select (as to still have access to them )
then I Used http://drupal.org/project/views_customfield (custom php feild)

and made a php feild using good old fastion php and used

<?php
// Get a list of all avalable things in this view 
print var_export($data, TRUE);
// the submission id 
$sid =  $data->sid;
?>

Then made some thing like this

<?php
// connect first ?

 $sid  = $data->sid;
// cid = the name of the webform componint in my case 7 & nid = my webform node id 
$typesql = "SELECT `data` FROM `webform_submitted_data` WHERE `sid` = '$sid' AND `nid` = '582' AND `cid` ='7'";
// query stuff 
$typeq = mysql_query($typesql);
$num1 = mysql_num_rows($typeq);
while($typeres = mysql_fetch_assoc($typeq)){
foreach ($typeres as $value) {
	//echo $value;
	switch ($value)
{
case 'a':
  echo " RED is Awesome <br/>";
  break;
case 'b':
 echo "GREEN is The Color of money<br/>";
  break;
// and so on 
default:
  echo "no dice ";
}
	
}
}

?>

so this did display the "data" - i guess i could have got the data dynamicly but i did not sorry ..

then i needed to expose the filter and views gave me a text box so i needed to change that to a list select box done in a new module like so ...


<?php
function tagmod_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'views_exposed_form') {

// find the filter name <select id="edit-colors" class="form-select" name="colors">
    $form['colors'] = array(
      '#type' => 'select',
      '#options' => array('' => t('<all>'), 'a' => 'RED', 'b' => 'Green','1a' => 'blue'),
      '#default_value' => 0,
      '#title' => t(''),
    );

  }
}
?>

And Life is Good 
cafuego’s picture

Please have a look at the 6.x-2.x-dev release, I've started work on using the field labels as descriptions in the Views UI.

cafuego’s picture

Version: 6.x-1.2 » 6.x-2.x-dev